[英]How to make 2 buttons in xml stick together (cover the whole space) in a linear layout?
我试图使线性布局中的2个按钮一起出现,或者比现在彼此靠拢的位置更近,但是我正在努力做到这一点。
下面是我的xml及其显示的内容,是否有可能实现我想要的内容,如果有人可以告诉我该怎么做,我将不胜感激。
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:text="Person 1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btnPerson1" />
<Button
android:text="Person 2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btnPerson2" />
</LinearLayout>
将android:layout_margin =“ 0”添加到按钮
为两个按钮设置负边距。
android:layout_marginTop=-8dp
android:layout_marginBottom=-8dp
尝试这个,
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0dp">
<Button
android:text="Person 1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".5"
android:id="@+id/btnPerson1" />
<Button
android:text="Person 2"
android:layout_marginTop="-12dp"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".5"
android:id="@+id/btnPerson2" />
</LinearLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.