2014-10-31 4 views
-1

Это мой layout.xml, в котором я хочу добавить фиксированный нижний колонтитул в нижней части списка. Также мне не удается изменить текущий макет. Этот макет содержит панель действий наверху. Самый первый относительный макет содержит весь макет, в том числе относительный макет панели действий, ниже которого у меня есть макет фрейма, содержащий listview. Я хочу, чтобы в этом представлении был нижний колонтитул, закрепленный внизу, содержащий некоторые кнопки изображения.Как добавить нижний колонтитул в макет?

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

    <!-- This acts as Actionbar --> 
    <RelativeLayout 
     android:id="@+id/relativeLayout" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:paddingRight="10dp" 
     android:orientation="horizontal" 
     android:background="@drawable/action_bar_background_strip" > 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:layout_alignParentLeft="true" 
      android:layout_centerVertical="true" 
      android:layout_marginLeft="20dp" 
      android:clickable="true" 
      android:onClick="toggleMenu" 
      android:contentDescription="@null" 
      android:src="@drawable/drawer_toggle_button" /> 

     <View 
      android:id="@+id/View1" 
      android:layout_width="1dp" 
      android:layout_height="fill_parent" 
      android:layout_marginLeft="20dp" 
      android:layout_toRightOf="@+id/imageView1" 
      android:background="#ffffff" /> 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:layout_toRightOf="@+id/View1" 
      android:layout_marginTop="8dp" 
      android:layout_marginLeft="20dp" 
      android:layout_marginRight="115dp" 
      android:text="Listview" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:textColor="#ffffff" 
      android:textStyle="bold" /> 

     <View 
      android:id="@+id/View2" 
      android:layout_width="1dp" 
      android:layout_height="fill_parent" 
      android:layout_toRightOf="@+id/textView1" 
      android:background="#ffffff" /> 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:layout_alignParentRight="true" 
      android:layout_centerVertical="true" 
      android:contentDescription="@null" 
      android:src="@drawable/icon" /> 

    </RelativeLayout> 

    <FrameLayout 
     android:layout_below="@+id/relativeLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

     <ListView 
      android:id="@+id/listView" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:choiceMode="multipleChoice" > 
     </ListView> 

    </FrameLayout> 

ответ

0

Например, вы можете: создать новый макет для footer и поместите его в нижней части своего родителя и сделать свой FrameLayout быть голос 'за' над вашим footer

Использование android:layout_above и android:layout_alignParentBottom свойств ваши макеты ...

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

<!-- This acts as Actionbar --> 
<RelativeLayout 
    android:id="@+id/relativeLayout" 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:paddingRight="10dp" 
    android:orientation="horizontal" 

    android:layout_alignParentTop="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true"> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_alignParentLeft="true" 
     android:layout_centerVertical="true" 
     android:layout_marginLeft="20dp" 
     android:clickable="true" 
     android:onClick="toggleMenu" 
     android:contentDescription="@null" /> 

    <View 
     android:id="@+id/View1" 
     android:layout_width="1dp" 
     android:layout_height="fill_parent" 
     android:layout_marginLeft="20dp" 
     android:layout_toRightOf="@+id/imageView1" 
     android:background="#ffffff" /> 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_toRightOf="@+id/View1" 
     android:layout_marginTop="8dp" 
     android:layout_marginLeft="20dp" 
     android:layout_marginRight="115dp" 
     android:text="Listview" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:textColor="#ffffff" 
     android:textStyle="bold" /> 

    <View 
     android:id="@+id/View2" 
     android:layout_width="1dp" 
     android:layout_height="fill_parent" 
     android:layout_toRightOf="@+id/textView1" 
     android:background="#ffffff" /> 

    <ImageView 
     android:id="@+id/imageView2" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_alignParentRight="true" 
     android:layout_centerVertical="true" 
     android:contentDescription="@null" /> 

</RelativeLayout> 

<FrameLayout 
    android:layout_below="@+id/relativeLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@+id/linearLayout"> 

    <ListView 
     android:id="@+id/listView" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:choiceMode="multipleChoice"> 
    </ListView> 
</FrameLayout> 


<LinearLayout 
    android:orientation="horizontal" 
    android:layout_alignParentBottom="true" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:id="@+id/linearLayout"> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="New Button" 
     android:id="@+id/button" /> 
</LinearLayout> 

+0

Я попробовал ваш путь, но линейная компоновка является прозрачной и listview отображается на фоне кнопки линейного макета. –

+0

Используйте атрибут layout_above для listview и дайте ему идентификатор линейного макета нижнего колонтитула. Это решит вашу проблему. –

0

Сделать footer.xml, как показано ниже:

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="50dp" 
    android:background="#5E616B" 
    android:gravity="center_horizontal" 
    android:orientation="horizontal" 
    android:weightSum="1" > 

    <ImageButton 
     android:id="@+id/btn_one" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_marginLeft="15dp" 
     android:layout_marginTop="2dp" 
     android:layout_weight=".2" 
     android:background="@drawable/footer_button_pressed" 
     android:src="@drawable/pingicon" /> 

    <ImageButton 
     android:id="@+id/btn_two" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_marginLeft="15dp" 
     android:layout_marginTop="2dp" 
     android:layout_weight=".2" 
     android:background="@drawable/footer_button_pressed" 
     android:src="@drawable/profile" /> 

    <ImageButton 
     android:id="@+id/btn_three" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_marginLeft="15dp" 
     android:layout_marginTop="2dp" 
     android:layout_weight=".2" 
     android:background="@drawable/footer_button_pressed" 
     android:src="@drawable/mycircle" /> 

    <ImageButton 
     android:id="@+id/btn_four" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_marginLeft="15dp" 
     android:layout_marginTop="2dp" 
     android:layout_weight=".2" 
     android:background="@drawable/footer_button_pressed" 
     android:src="@drawable/sendping" /> 

    <ImageButton 
     android:id="@+id/btn_five" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_marginLeft="15dp" 
     android:layout_marginTop="2dp" 
     android:layout_weight=".2" 
     android:background="@drawable/footer_button_pressed" 
     android:src="@drawable/settings" /> 
</LinearLayout> 

Идея здесь simple.Take линейная схема с weightsum 1 и разделить этот вес их дети. Вот я взял 5 кнопок изображения и распределял вес .2 каждому из них. Не забудьте установить ориентацию макета вертикально.

Затем включает нижний колонтитул в макете, как:

<include 
     android:id="@+id/footer" 
     layout="@layout/footer" /> 

Затем создать свой Scrollview как:

<FrameLayout 
     android:layout_below="@+id/relativeLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@+id/footer" 
     android:layout_below="@+id/header"(IF ANY) > 

     <ListView 
      android:id="@+id/listView" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:choiceMode="multipleChoice" > 
     </ListView> 

    </FrameLayout> 
0
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/relativeLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <ListView 
     android:id="@+id/listView1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@+id/linearLayout1" > 
    </ListView> 

<!-- Footer linear layout --> 

    <LinearLayout 
     android:id="@+id/linearLayout1" 
     android:layout_width="match_parent" 
     android:layout_height="55dp" 
     android:weightSum="5" 
     android:layout_marginBottom="-5dp" 
     android:orientation="horizontal" 
     android:layout_alignParentBottom="true" > 

     <ImageButton 
      android:id="@+id/imageButton1" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:layout_marginLeft="-4.5dp" 
      android:layout_marginRight="-4dp" 
      android:layout_marginTop="-5dp" 
      android:contentDescription="@null" 
      android:src="@drawable/filing_button_icon" /> 

     <ImageButton 
      android:id="@+id/imageButton2" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:layout_marginLeft="-4.5dp" 
      android:layout_marginRight="-4.5dp" 
      android:layout_marginTop="-5dp" 
      android:contentDescription="@null" 
      android:src="@drawable/delete_icon" /> 

     <ImageButton 
      android:id="@+id/imageButton3" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:layout_marginLeft="-4dp" 
      android:layout_marginRight="-4.5dp" 
      android:layout_marginTop="-5dp" 
      android:contentDescription="@null" 
      android:src="@drawable/reply_all_icon" /> 

     <ImageButton 
      android:id="@+id/imageButton4" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:layout_marginLeft="-4dp" 
      android:layout_marginRight="-4.5dp" 
      android:layout_marginTop="-5dp" 
      android:contentDescription="@null" 
      android:src="@drawable/reply_icon" /> 

     <ImageButton 
      android:id="@+id/imageButton5" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:layout_marginLeft="-4dp" 
      android:layout_marginRight="-4.5dp" 
      android:layout_marginTop="-5dp" 
      android:contentDescription="@null" 
      android:src="@drawable/forward_icon" /> 

    </LinearLayout> 

</RelativeLayout> 
Смежные вопросы