2012-11-22 46 views
0

即将在.xml文件。我写下面的,而不是指定布局不是在底部

<LinearLayout 
    android:id="@+id/layoutContacts" 
    android:layout_width="match_parent" 
    android:layout_height="fill_parent" 
    android:layout_marginTop="50dp" 
    android:visibility="gone" 
    android:orientation="vertical"> 

    <AutoCompleteTextView 
     android:id="@+id/autoCompleteTextViewContactEntered" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:hint="Contact Number" > 

    <requestFocus /> 
    </AutoCompleteTextView> 

    <LinearLayout 
     android:id="@+id/layoutDownButtons" 
     android:gravity="bottom" 
     android:layout_gravity="bottom" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 
     <Button 
      android:text="Balance" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:onClick="showBalance"/> 
     <Button 
      android:text="Settings" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1.1" 
      android:onClick="showSettings"/> 

    </LinearLayout> 
</LinearLayout> 

我想机器人:ID = “@ + ID/layoutDownButtons” 在底部。僵尸它不是在底部。我编写了android:gravity =“bottom” android:layout_gravity =“bottom”,它仍然不起作用。

+0

发布您的完整xml代码。 –

回答

1

该解决方案可以帮助您吗?

<LinearLayout 
    android:id="@+id/layoutContacts" 
    android:layout_width="match_parent" 
    android:layout_height="fill_parent" 
    android:layout_marginTop="50dp" 
    android:layout_weight="1" 
    android:orientation="vertical" 
    android:visibility="gone" > 

    <AutoCompleteTextView 
     android:id="@+id/autoCompleteTextViewContactEntered" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:hint="Contact Number" > 

     <requestFocus /> 
    </AutoCompleteTextView> 
</LinearLayout> 

<LinearLayout 
    android:id="@+id/layoutDownButtons" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:gravity="bottom" 
    android:orientation="horizontal" > 

    <Button 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:onClick="showBalance" 
     android:text="Balance" /> 

    <Button 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1.1" 
     android:onClick="showSettings" 
     android:text="Settings" /> 
</LinearLayout> 
0

而不是第一个“线性布局”你可以使用一个“相对布局”,然后写的android:layout_alignParentBottom在layoutDownButtons“的LinearLayout” =“真”。