2013-10-10 34 views
0

我在萬畝Android應用程序設計的一個底部菜單適應底部菜單中的所有屏幕

正常工作中,我對

工作,但如果我改變了屏幕,它不填充所有屏幕屏幕的寬度,即使我設定的RelativeLayout的寬度FILL_PARENT

這裏是菜單的代碼:

<RelativeLayout 
    android:id="@+id/bar_bas" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    android:orientation="horizontal" > 

    <RelativeLayout 
     android:id="@+id/relativeLayout1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:background="@null" 
     android:clickable="true" > 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@drawable/right_left" 
      android:text="test" 
      android:textColor="#bfd2b0" /> 
    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/relativeLayout2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_toRightOf="@+id/relativeLayout1" 
     android:clickable="true" > 

     <Button 
      android:id="@+id/btn_circle" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@drawable/left_circle" 
      android:text="test" 
      android:textColor="#bfd2b0" /> 
    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/relativeLayout3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_marginLeft="-40dp" 
     android:layout_toRightOf="@+id/relativeLayout2" 
     android:clickable="true" > 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@drawable/circle" 
      android:text="test" 
      android:textColor="#bfd2b0" /> 
    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/relativeLayout4" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="-38dp" 
     android:layout_alignParentBottom="true" 
     android:layout_toRightOf="@+id/relativeLayout3" 
     android:clickable="true" > 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@drawable/right_circle" 
      android:text="test" 
      android:textColor="#bfd2b0" /> 
    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/relativeLayout5" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_toRightOf="@+id/relativeLayout4" 
     android:clickable="true" > 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@drawable/right_left" 
      android:text="test" 
      android:textColor="#bfd2b0" /> 
    </RelativeLayout> 
</RelativeLayout> 

,這裏是它是如何在我的屏幕:http://s23.postimg.org/m3h37utuj/image.png 這裏等屏幕(平板電腦屏幕)的例子:http://s24.postimg.org/hd0ibrahh/image.png

我怎麼能解決這個問題

回答

0
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/bar_bas" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:orientation="horizontal" > 

<Button 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:background="#ff00ff" 
    android:text="test" 
    android:layout_weight="1" 
    android:textColor="#bfd2b0" /> 

<Button 
    android:id="@+id/btn_circle" 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:background="#FF0000" 
    android:text="test" 
    android:layout_weight="1" 
    android:textColor="#bfd2b0" /> 

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="#ff00AA" 
    android:text="test" 
    android:layout_weight="1" 
    android:textColor="#bfd2b0" /> 

<Button 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:background="#ffaaff" 
    android:text="test" 
    android:layout_weight="1" 
    android:textColor="#bfd2b0" /> 

<Button 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:background="#00AAff" 
    android:text="test" 
    android:layout_weight="1" 
    android:textColor="#bfd2b0" /> 

</LinearLayout> 

檢查這一項,wrap_parent意味着它會採取更少的空間,因爲它可以。

0

試試這個..

<LinearLayout 
    android:id="@+id/bar_bas" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    android:orientation="horizontal" >  

     <Button 
      android:layout_height="0dp" 
      android:layout_weight="0.2" 
      android:layout_height="wrap_content" 
      android:background="@drawable/right_left" 
      android:text="test" 
      android:textColor="#bfd2b0" /> 

     <Button 
      android:id="@+id/btn_circle" 
      android:layout_height="0dp" 
      android:layout_weight="0.2" 
      android:layout_height="wrap_content" 
      android:background="@drawable/left_circle" 
      android:text="test" 
      android:textColor="#bfd2b0" />   

     <Button 
      android:layout_height="0dp" 
      android:layout_weight="0.2" 
      android:layout_height="wrap_content" 
      android:background="@drawable/circle" 
      android:text="test" 
      android:textColor="#bfd2b0" />  

     <Button 
      android:layout_height="0dp" 
      android:layout_weight="0.2" 
      android:layout_height="wrap_content" 
      android:background="@drawable/right_circle" 
      android:text="test" 
      android:textColor="#bfd2b0" />   

     <Button 
      android:layout_height="0dp" 
      android:layout_weight="0.2" 
      android:layout_height="wrap_content" 
      android:background="@drawable/right_left" 
      android:text="test" 
      android:textColor="#bfd2b0" /> 

</LinearLayout>