在屏幕底部对齐Fragment LinearLayout

时间:2014-07-30 15:57:10

标签: android android-layout layout android-fragments

我正在尝试使用重力底部在屏幕底部对齐片段,但这对我不起作用。片段代码如下:

<!-- Text field and possibly soft menu button above the keypad where
     the digits are displayed. -->
<LinearLayout
    android:id="@+id/digits_container"
    android:layout_width="match_parent"
    android:layout_height="0px"
    android:layout_weight="@integer/dialpad_layout_weight_digits"
    android:layout_marginTop="@dimen/dialpad_vertical_margin"
    android:gravity="center"
    android:background="@drawable/dialpad_background" >

    <com.example.exd.dialpad.DigitsEditText
        android:id="@+id/digits"
        android:layout_width="0dip"
        android:layout_weight="1"
        android:layout_height="match_parent"
        android:gravity="center"
        android:textAppearance="@style/DialtactsDigitsTextAppearance"
        android:textColor="?android:attr/textColorPrimary"
        android:nextFocusRight="@+id/overflow_menu"
        android:background="@android:color/transparent" />

    <ImageButton
        android:id="@+id/deleteButton"
        android:layout_width="56dip"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:gravity="center"
        android:state_enabled="false"
        android:background="?android:attr/selectableItemBackground"
        android:contentDescription="@string/description_delete_button"
        android:src="@drawable/ic_dial_action_delete" />
</LinearLayout>

<!-- Keypad section -->
<include layout="@layout/dialpad"
    android:layout_weight="1"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent" />

<View
   android:layout_width="match_parent"
   android:layout_height="@dimen/dialpad_vertical_margin"
   android:background="#66000000"/>

<!-- left and right paddings will be modified by the code. See DialpadFragment. -->
<FrameLayout
    android:id="@+id/dialButtonContainer"
    android:layout_width="match_parent"
    android:layout_height="0px"
    android:layout_weight="@integer/dialpad_layout_weight_additional_buttons"
    android:layout_gravity="center_horizontal"
    android:background="@drawable/dialpad_background">

    <ImageButton
        android:id="@+id/dialButton"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:state_enabled="false"
        android:background="@drawable/btn_call"
        android:contentDescription="@string/description_dial_button"
        android:src="@drawable/ic_dial_action_call" />

</FrameLayout>

<!-- "Dialpad chooser" UI, shown only when the user brings up the
     Dialer while a call is already in progress.
     When this UI is visible, the other Dialer elements
     (the textfield/button and the dialpad) are hidden. -->
<ListView android:id="@+id/dialpadChooser"
    android:layout_width="match_parent"
    android:layout_height="1dip"
    android:layout_weight="1"
/>

我以编程方式添加了这个片段:

 FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
 DialpadFragment fragment= DialpadFragment.newInstance();
 ft.add(R.id.contact_list,fragment);
 ft.addToBackStack("DialPad");
 ft.commit(); 

contact_list片段xml:

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
          android:name="com.example.exd.ContactsListFragment"
          android:id="@+id/contact_list"
          android:layout_height="match_parent"
          android:layout_width="match_parent"/>

如何在底部显示此片段,因为它当前显示在屏幕顶部。

0 个答案:

没有答案