我有2个嵌套在Horizontal LinearLayout中的按钮,我想将它们对齐到屏幕的底部。我已将LinearLayout的 <LinearLayout
android:id="@+id/hourlyDailyLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
<Button
android:id="@+id/hourlyButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/hourly"
android:textColor="#ffffffff"
/>
<Button
android:id="@+id/dailyButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/daily"
android:textColor="#ffffffff"
/>
</LinearLayout>
属性设置为1&amp; 2个按钮的{{1}}属性也是1&amp;我得到了这个结果:
我在按钮周围有这个奇怪的空间,我想消除它。怎么样?
以下是XML代码:
{{1}}
答案 0 :(得分:1)
按钮默认有填充。他们打击的方法是设置负边距
<Button
android:id="@+id/dailyButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/daily"
android:textColor="#ffffffff"
android:layout_marginBottom="-5dp"
/>
答案 1 :(得分:-2)
<Button
android:id="@+id/hourlyButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/hourly"
android:textColor="#ffffffff"
/>
<Button
android:id="@+id/dailyButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/daily"
android:textColor="#ffffffff"
/>
将宽度设置为0dp