我正在尝试制作一个计算器应用程序。我想在我的一些按钮上方设置一个小文本。我正在使用 LinearLayout 放置按钮 - 每行 5 个。我应该在按钮上方使用一个小的 TextView 还是我可以使用按钮的任何属性?但是在这种情况下,如何确保文本位于每个按钮的正上方?
问问题
426 次
4 回答
1
您可以使用RelativeLayout
代替和使用和/或LinearLayout
的属性android:layout_below=
android:layout_above=
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Some Text" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:onClick="doSomething"
android:text="This Button" />
于 2013-04-21T14:05:52.580 回答
1
在你的LinearLayout
for 5 个按钮中,每个元素应该是另一个LinearLayout
,这次是垂直的,然后使用 aTextView
作为文本,然后是 aButton
作为按钮。
<LinearView orientation='horizontal'>
<LinearView orientation='vertical'>
<TextView />
<Button />
</LinearView>
<LinearView orientation='vertical'>
...
</LinearView>
...
</LinearView>
于 2013-04-21T14:08:17.950 回答
0
您可以使用GridLayout或者您可以为每个按钮添加另一个垂直线性布局,您可以在其中放置 textview 和按钮。
于 2013-04-21T14:04:47.497 回答
0
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:text=button"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
于 2013-04-21T14:12:17.427 回答