[英]Why those 2 layout looks different?
有人可以向我解释我的误会吗? 对于这两种布局,我都有layout_height = 140dp。 但是为什么它们看起来不同? 我该如何解决?
这是完整的xml: https : //www.pastiebin.com/59ad4fa3d00ba https://www.pastiebin.com/59ad4fd6a20c0
谢谢。
第一个是:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="140dp"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<Button
android:id="@+id/discount_apply"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:background="@android:color/holo_green_dark"
android:paddingLeft="10dp"
android:text="ПРИМЕНИТЬ" />
<Button
android:id="@+id/discount_cancel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:background="@android:color/white"
android:paddingLeft="10dp"
android:text="ОТМЕНИТЬ"
android:textAlignment="center"
android:textColor="@android:color/black" />
</LinearLayout>
第二个是:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="140dp"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:id="@+id/CashButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawableLeft="@mipmap/cash"
android:paddingLeft="10dp"
android:layout_marginRight="2dp"
android:background="@android:color/holo_green_dark"
android:layout_weight="1"
android:text="НАЛИЧНЫЕ" />
<Button
android:id="@+id/CardButton"
android:layout_width="match_parent"
android:background="@android:color/white"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:drawableLeft="@mipmap/visa"
android:textColor="@android:color/black"
android:textAlignment="center"
android:layout_weight="1"
android:paddingLeft="10dp"
android:text="БАНКОВСКАЯ \n КАРТА" />
</LinearLayout>
从这么多的代码中很难看出它的安静,但是在第二个布局中,我在LinearLayout中看到layout_weight = 1。 如果此LinearLayout的父级是方向设置为Vertical的另一个LinearLayout,则此偏移将覆盖您的高度设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.