![](/img/trans.png)
[英]aligning button to bottom within linearlayout parent with minheight
[英]Android xml ,2 button use minheight in a LinearLayout and 2 button is not in a line
像这样的xml
<Linearlayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="horizontal">
<Button
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:minHeight="40dp"
...../>
<Button
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:minHeight="40dp"
...../>
<LinearLayout/>
我希望两个按钮对齐,但是就像上面的图片一样。
当我删除最小高度时,
所以任何人都知道为什么Minheight会使右按钮稍微降低一点。
我宁愿使用RelativeLayout,因为您对元素有更多的控制权。
如果没有帮助,则将android:layout_alignParentRight =“ true”添加到您乐意放在右侧的按钮上,然后将您想要的按钮添加到左侧android:layout_toLeftOf =“ @ + id / LocationIDdb ”,其中包含您设置为向右对齐的ID。
您对所有视图使用了错误的属性,请尝试这种方式,希望这将帮助您解决问题。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:minHeight="40dp"/>
<Button
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:minHeight="40dp"/>
</LinearLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.