0

New to android.I am using radio Button in my android app

questionbtnD = (RadioButton)findViewById(R.id.optionD);
questionbtnD.setText(Html.fromHtml(dq.get(id).getOptions().get(3).toString().trim()));

and text coming is like enter image description here

<![CDATA[ <p> Won't compile because of line (1) – constructor can't be private </p> ]]>

but its is not properly aligned can any body help me how to align this.

Bat
  • 135
  • 2
  • 9

2 Answers2

0

This should give you an idea how to use the LayoutParams

  RadioGroup.LayoutParams layoutParams = new RadioGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        layoutParams.setMargins(0, 32, 0, 0);
        RadioButton rButton = new RadioButton(getActivity());
        rButton.setText("stuff");
        rButton.setLayoutParams(layoutParams);
        rButton.setPadding(140, 0, 40, 0);
        radioGroupPair.addView(rButton);

This is the xml

<RadioGroup
            android:id="@+id/radioGroupPair"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
</RadioGroup>
Murat Karagöz
  • 35,401
  • 16
  • 78
  • 107
  • Thanks Murat fro reply, I already used for Layout params like wrap_Content, Margins and padding but not working for me. – Bat Jun 09 '16 at 14:43
  • @Sahil This is exactly how I used it in my code and its perfectly aligned. Maybe us some dummy text to see that the strings are not too long to fit. – Murat Karagöz Jun 09 '16 at 14:47
  • If I am not using HTML Content Then Its Working fine but with Html only it is giving problem – Bat Jun 09 '16 at 14:57
0

Finally, I found the issue in HTML I was using

which was giving one extra line due to which I was getting extra one lank Line Now I remove

Tag

<![CDATA[     Won't compile because of line (1) – constructor can't be private  ]]>

So Its working fine for me now

Bat
  • 135
  • 2
  • 9