Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to vertically-align:top a Radio button to a multiline text?

As you can see, I got a simple RadioGroup and its options.

<RadioGroup
    android:id="@+id/radio_report_problems"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="20dp" >

    <RadioButton
        android:id="@+id/radiooption_1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/report_problem_rd_opt_1" />

    <RadioButton
        android:id="@+id/radiooption_2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/report_problem_rd_opt_2" />

    .....

</RadioGroup>

My problem is that the bullet sits at the middle of the text, instead of starting at the first line

printscreen

Without using tableView, or linearLayout, is there a simple way to achieve this using RadioGroup only?

Thank you.

like image 432
neoswf Avatar asked Sep 11 '25 22:09

neoswf


2 Answers

i used

android:gravity="top"

and it works

see this: enter image description here

like image 139
M Moersalin Avatar answered Sep 14 '25 11:09

M Moersalin


You could extend RadioButton and override the onDraw method to draw the button aligned with the top of the text. The code for drawing that button is actually inside of CompoundButton (RadioButton extends from that), so that should be your starting point for how to draw the button. Source

Personally I don't think there's anything wrong with the button aligning to the center, but that's beside the point.

like image 32
Karakuri Avatar answered Sep 14 '25 12:09

Karakuri