1

我有一个底部有 3 个按钮的向上按钮。当我在模拟器上测试它时,会出现全屏。当我在我的设备上测试它时,下面的按钮不显示。就像分辨率不正确一样。这是我的 xml 布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@raw/mexicanbg"
android:orientation="vertical" >




<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <Button
        android:id="@+id/buttonbacksubreclist"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:background="@drawable/back_button"
        android:onClick="back" />

    <TextView
        android:id="@+id/textViewreclist"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginLeft="45dp"
        android:text="@string/reclist"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#000000" />

 </LinearLayout>


 <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >
 </LinearLayout>

 <ListView
    android:id="@+id/android:list"
    android:layout_width="fill_parent"
    android:layout_height="382dp" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="362dp" >

<Button
    android:id="@+id/buttonRecipes"
    android:layout_width="108dp"
    android:layout_height="wrap_content"
    android:background="@drawable/menu_xrecipes"
    android:onClick="recipe"
    android:text="@string/rec" />

<Button
    android:id="@+id/buttonGroList"
    android:layout_width="110dp"
    android:layout_height="wrap_content"
    android:background="@drawable/menu_xgrocery"
    android:onClick="grocerylist"
    android:text="@string/grolist" />

<Button
    android:id="@+id/button1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/menu_xmore"
    android:text="@string/more" />
</LinearLayout>

</LinearLayout>

编辑:新布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@raw/mexicanbg"
android:orientation="vertical" >




<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <Button
        android:id="@+id/buttonbacksubreclist"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:background="@drawable/back_button"
        android:onClick="back" />

    <TextView
        android:id="@+id/textViewreclist"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginLeft="45dp"
        android:text="@string/reclist"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#000000" />

</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >
</LinearLayout>


<ListView
    android:id="@+id/android:list"
    android:layout_width="fill_parent"
    android:layout_height="382dp" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="362dp" >




<Button
    android:id="@+id/buttonRecipes"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@drawable/menu_xrecipes"
    android:onClick="recipe"
    android:text="@string/rec" />



<Button
    android:id="@+id/buttonGroList"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@drawable/menu_xgrocery"
    android:onClick="grocerylist"
    android:text="@string/grolist" />



<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@drawable/menu_xmore"
    android:text="@string/more" />

</LinearLayout>

</LinearLayout>
4

4 回答 4

1

试试这个:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@raw/mexicanbg"
    android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/buttonbacksubreclist"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:background="@drawable/back_button"
            android:onClick="back" />

        <TextView
            android:id="@+id/textViewreclist"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginLeft="45dp"
            android:text="@string/reclist"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#000000" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/real1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <ListView
            android:id="@+id/android:list"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:scrollX="true" />
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_below="@+id/real1" >

        <Button
            android:id="@+id/buttonRecipes"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/menu_xrecipes"
            android:onClick="recipe"
            android:text="@string/rec" />

        <Button
            android:id="@+id/buttonGroList"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/menu_xgrocery"
            android:onClick="grocerylist"
            android:text="@string/grolist" />

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/menu_xmore"
            android:text="@string/more" />
    </RelativeLayout>

</RelativeLayout>
于 2012-09-20T11:10:40.680 回答
0

用相对布局替换最后一个线性布局,并指定android:layout_alignParentBottom="true" 并将 RelativeLayout 作为您的根布局

于 2012-09-20T11:03:42.207 回答
0

试试这个 :

  <?xml version="1.0" encoding="utf-8"?>
   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
     android:background="@raw/mexicanbg"
      android:orientation="vertical" >

 <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<Button
    android:id="@+id/buttonbacksubreclist"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="15dp"
    android:background="@drawable/back_button"
    android:onClick="back" />

<TextView
    android:id="@+id/textViewreclist"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginLeft="45dp"
    android:text="@string/reclist"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="#000000" />

   </LinearLayout>

   <LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp" >



  <ListView
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="200dp" />
 </LinearLayout>

 <LinearLayout
 android:layout_width="match_parent"
 android:layout_height="wrap_content" >




<Button
android:id="@+id/buttonRecipes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/menu_xrecipes"
android:onClick="recipe"
android:text="@string/rec" />



<Button
android:id="@+id/buttonGroList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/menu_xgrocery"
android:onClick="grocerylist"
android:text="@string/grolist" />



<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/menu_xmore"
android:text="@string/more" />

 </LinearLayout>

   </LinearLayout>
于 2012-09-20T11:25:00.643 回答
0

我找到了答案……问题不在于按钮……而在于我的 ListView。我没有把重量放在我的列表视图上。这是我最终的 xml 布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@raw/mexicanbg">






   <LinearLayout
   android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_width="fill_parent"
        android:layout_height="50dip"
        android:orientation="horizontal"
        android:background="@drawable/xpage_label">




    <TextView
        android:id="@+id/textViewrecipe"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        android:layout_marginBottom="10dp"
        android:text="@string/rec"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#000000" />

 </LinearLayout>








 <ListView
    android:id="@+id/android:list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1" />

 <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content" >

     <Button
         android:id="@+id/button3"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_weight="1"
         android:background="@drawable/menu_xrecipes"
         android:onClick="recipe" />

     <Button
         android:id="@+id/buttonGroList"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_weight="1"
         android:background="@drawable/menu_xgrocery"
         android:onClick="grocerylist" />

     <Button
         android:id="@+id/button1"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_weight="1"
         android:background="@drawable/menu_xmore" />
 </LinearLayout>

</LinearLayout>
于 2012-09-20T11:32:44.623 回答