首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安卓: ListView和TabWidget: ListView通过TabWidget

安卓: ListView和TabWidget: ListView通过TabWidget
EN

Stack Overflow用户
提问于 2012-08-29 22:12:47
回答 2查看 1.1K关注 0票数 1

我在我的android项目中使用TabWidget,在视图中有一个listView和一个FrameLayout。问题是,当ListView高于屏幕高度时,选项卡是不可见的,因为列表视图会越过选项卡。

我不知道如何设置选项卡上方的listView。

这是我的观点:

代码语言:javascript
复制
<?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="wrap_content" >

    <FrameLayout
        android:id="@+id/frameLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:background="#ffffff"
        android:minHeight="44dp" >

    </FrameLayout>


    <ListView
        android:id="@+id/NewsCategorieslistView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:cacheColorHint="#00000000" 
        android:layout_below="@+id/frameLayout"
        >

    </ListView>

</RelativeLayout>

这是我的选项卡视图:

代码语言:javascript
复制
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:divider="@null" >

    </TabWidget>

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        >
    </FrameLayout>
</RelativeLayout>
</TabHost>

非常感谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-08-30 06:19:31

我已经找到了解决方案:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <RelativeLayout 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent">

        <FrameLayout android:id="@android:id/tabcontent"
             android:layout_width="fill_parent" 
             android:layout_height="fill_parent"
             android:layout_alignParentTop="true" 
             android:layout_above="@android:id/tabs" />

        <TabWidget android:id="@android:id/tabs"
             android:layout_width="fill_parent" 
             android:layout_height="wrap_content"
             android:layout_alignParentBottom="true" />

    </RelativeLayout>

</TabHost>
票数 3
EN

Stack Overflow用户

发布于 2012-08-29 22:27:35

在您的tab.xml(选项卡活动的布局)中尝试此选项

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp" />
    </LinearLayout>
</TabHost>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12179949

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档