如您所见,我有一个简单的RadioGroup及其选项。
<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>
我的问题是子弹位于文本中间,而不是从第一行开始
不使用tableView或linearLayout,是否有一种简单的方法可以使用仅限RadioGroup 实现此目的?
谢谢。
答案 0 :(得分:3)
您可以扩展RadioButton
并覆盖onDraw
方法以绘制与文本顶部对齐的按钮。用于绘制该按钮的代码实际上位于CompoundButton
内(RadioButton
从此延伸),因此应该是如何绘制按钮的起点。 Source
就我个人而言,我并不认为按钮与中心对齐有什么问题,但这就是重点。
答案 1 :(得分:0)
答案 2 :(得分:-2)
设置重力顶部|底部的单选按钮
radioButton.setGravity(Gravity.TOP | Gravity.BOTTOM);