Android,意外的按钮左右填充
我想做一个按钮,左右顶部和底部的填充物是一样的。 但我得到的是这样的东西: 以下是布局图:Android,意外的按钮左右填充,android,user-interface,Android,User Interface,我想做一个按钮,左右顶部和底部的填充物是一样的。 但我得到的是这样的东西: 以下是布局图: <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/people_number_label" android:te
<RelativeLayout android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/people_number_label"
android:text="@string/number_of_people"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/people_number"
android:layout_toRightOf="@+id/people_number_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
因此,按钮的工作方式是具有背景可绘制的文本视图。你看到的就是那个拖拉的。文本将居中于该绘图区域内,如您在此处所见。如果您希望文本显示与提示一致,则按钮将不适用于您。您最好只是将其设置为文本视图,并将xml背景设置为可绘制的圆形矩形,使其看起来像按钮,但实际上并非如此
另一件事,你可以尝试做它对齐两个视图的基线。这将对齐文本,但可能会将提示按到屏幕下方代码中是否有更改?代码中没有更改