0

我有一个正在处理的标题,我让按钮呈现在一行中,但是一个按钮不适合屏幕,并且按钮之间有一个空格。

到目前为止,这是我的标题布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" 
android:layout_height="fill_parent">


 <Button android:id="@+id/home"
  android:layout_width="0dp" 
  android:orientation="horizontal"
  android:layout_height="10dp"
  android:layout_weight="1"
  android:text="Home"
/>

<Button android:id="@+id/questions"
 android:layout_width="0dp" 
 android:layout_height="10dp"
 android:orientation="horizontal"
 android:layout_weight="1"
 android:text="Questions"
android:layout_toRightOf="@+id/home"  />  


 <Button android:id="@+id/businesses"
  android:layout_width="0dp" 
  android:layout_height="10dp"
  android:orientation="horizontal"
  android:layout_weight="1"
  android:text="Businesses"
  android:layout_toRightOf="@+id/questions"
 />  

 <Button android:id="@+id/learn"
  android:layout_width="0dp" 
  android:layout_height="10dp"
  android:layout_weight="1"
  android:orientation="horizontal"
  android:text="Learn"
  android:layout_toRightOf="@+id/businesses"
 />  


 <Button android:id="@+id/extra_help"
  android:layout_width="0dp" 
  android:layout_height="10dp"
  android:orientation="horizontal"
  android:layout_weight="1"
  android:text="Help"
  android:layout_toRightOf="@+id/learn"
/>  
</LinearLayout>

如何使每个按钮更小,并使其之间没有空间?另外,哪些设备的屏幕更窄?如何确保标题适合所有屏幕?

谢谢!

4

2 回答 2

1

您可以使用 aLinearLayout并将每个Button's设置layout_width0dplayout_weightto 1。这样,整个空间LinearLayout将平均分布在您Button的 s 中。

于 2012-05-18T01:21:02.323 回答
0

使用RelativeLayout而不是LinearLayout. 比您拥有的任何屏幕都适合。

于 2012-05-18T03:52:29.863 回答