我想要三个按钮,间距相等,大小相等。当其中一个按钮的文本超过3个单词(新行)时,按钮会下降,如图所示。有没有办法修复相同的三个按钮在同一行中的位置?我尝试使用TableLayout
/ Row
,但没有帮助。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/linearLayout1"
android:layout_alignParentBottom="true" android:layout_width="fill_parent"
android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android">
<Button android:text="Trade"
android:layout_weight="1" android:layout_height="wrap_content"
android:layout_width="0dip" ></Button>
<Button android:text="Set Alert"![enter image description here][2]
android:layout_weight="1" android:layout_height="wrap_content"
android:layout_width="0dip" ></Button>
<Button android:text="Add to watchlist"
android:layout_weight="1" android:layout_height="wrap_content"
android:layout_width="0dip"></Button>
</LinearLayout>
答案 0 :(得分:0)
我试过了,当我采用你的上面的布局并将3:按钮上的android:layout_height设置为“fill_parent”时,它对我有用。
(虽然这是一个有趣的问题,但不确定为什么最后一个按钮有点偏移。)
答案 1 :(得分:-1)
如果您希望按钮的行不小于/大于特定数量,您可以尝试:
Button b = null;
b.setMaxLines(1);
b.setMinLines(1);
<强>更新强>
b.setSingleLine();