2

我想添加一个页脚视图,一个列表视图中加载的元素的计数器。我想知道我应该把页脚视图放在哪里。我的列表视图中已经有一个,我想我不能把它放在那里,因为我希望它一直可见,而不是像我所拥有的那样深入到它的底部。

代码:

列表显示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:orientation="vertical">

<ListView
    android:id="@+id/lista"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:stackFromBottom="false"
    android:transcriptMode="normal"
    />
</LinearLayout>

选项卡的代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainTabActivity" >
<TabHost
    android:id="@android:id/tabhost"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true" >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical|fill_vertical|fill_horizontal" >
        </TabWidget>
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
            <LinearLayout
                android:id="@+id/tab1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" >                   
                <ListView
                    android:id="@+id/lista"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:stackFromBottom="false"
                    android:transcriptMode="normal"
                    />
            </LinearLayout>
            <LinearLayout
                android:id="b"
            </LinearLayout>

            <LinearLayout
                android:id="c"
            </LinearLayout>                
            <LinearLayout
                android:id="d"
            </LinearLayout>                            
        </FrameLayout>
    </LinearLayout>                      
</TabHost>     

我有这个:http: //imageshack.us/photo/my-images/23/6a3t.jpg/

我想要这个:http: //imageshack.us/photo/my-images/809/kesm.jpg/

4

3 回答 3

2

如果将具有 match_parent 宽度和高度的 FrameLayout 放在 LinearLayout 中,所有内容都将隐藏在屏幕之外。

有两种形式可以添加该页脚:

首先,使用以下尺寸设置框架布局:

<FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

二,使用RelativeLayout并将所有内容设置为其他内容,如果要在内容上方添加页脚,则使用layout_alignParentBottom = true添加页脚,如果希望页脚与内容一起添加,请在最后一个视图下方。

于 2013-07-26T09:11:44.450 回答
0

也许这可以帮助你。

创建一个名为的文件footer.xml 并将此代码添加到其中

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="40dp"
    android:layout_gravity="bottom"
    android:gravity="bottom"
 android:layout_weight=".15"
    android:orientation="horizontal"
    android:background="@drawable/bckkaup" >
    <ImageView
        android:id="@+id/lborder"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".14"
        android:background="@drawable/action_bar_left_button"
        android:src="@drawable/over_9"
        android:scaleType="fitXY" />
    <ImageView
        android:id="@+id/unknown"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".14"
        android:background="@drawable/action_bar_left_button"
        android:src="@drawable/cartoon_9"
        android:scaleType="fitXY" />

    <ImageView
        android:id="@+id/open"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".14"
        android:background="@drawable/action_bar_left_button"
        android:src="@drawable/gallery_9"
        android:scaleType="fitXY"
        android:hapticFeedbackEnabled="true"
        android:soundEffectsEnabled="true"

        />

    <View
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.03" 
        android:src="@drawable/action_bar_right_button"
        android:background="@drawable/action_bar_left_button"
        />

    <ImageView
        android:id="@+id/opencam"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".14"
        android:background="@drawable/action_bar_left_button"
        android:src="@drawable/camera_9"
        android:scaleType="fitXY"
        android:hapticFeedbackEnabled="true"
        android:soundEffectsEnabled="true"
        />
    <ImageView
        android:id="@+id/color"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".14"
        android:background="@drawable/action_bar_left_button"
        android:src="@drawable/stylish_9"
        android:scaleType="fitXY" />
        <ImageView
        android:id="@+id/rborder"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="@drawable/action_bar_left_button"
        android:src="@drawable/frame_9"
        android:layout_weight=".14" 
        android:scaleType="fitXY"/>


</LinearLayout>

然后在您main layout 添加此代码

 <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="40dp"
    android:id="@+id/down"
    android:layout_alignParentBottom="true" >

    <include
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        layout="@layout/footer" >

    </include>
</LinearLayout>    

这会给你一个页脚。您也可以更改重力以使其成为标题。我知道您要标签,但我想我应该与您分享它,也许它无论如何都会使您受益。

于 2013-07-26T10:18:36.473 回答
0

怎么样ListView.addFooterView

从文档:

添加一个固定视图以显示在列表的底部。如果 addFooterView 被多次调用,视图将按照它们添加的顺序出现。如果需要,使用此调用添加的视图可以成为焦点。

注意:在调用 setAdapter 之前调用它。这样 ListView 就可以将提供的光标与一个也将考虑页眉和页脚视图的光标包装起来。

于 2013-07-26T09:00:52.957 回答