Android学习—解决ListView部分内容被Tabhost遮盖问题

问题:tabhost固定在底部,某个tab中存在Listview,运行起来后发现如果listview中的列表内容比较多(超过一屏时),就会出现部分内容被tabhost遮盖了。

Android学习—解决ListView部分内容被Tabhost遮盖问题

原Listview布局文件

<ListView

        android:id="@+id/listBudgetSet"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginLeft="4dp"

        android:layout_marginRight="4dp">
</ListView>

后来经过多次调试,发现可以通过配置Listview解决这个问题,下面是重新配置listview的:

在<ListView>中加上android:layout_weight="1" ,并且在listview的下方加一个布局,这是用于留出tabhost显示的空间(也就是让listview的滚动条增长70dp)

<ListView

        android:id="@+id/listBudgetSet"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginLeft="4dp"

        android:layout_marginRight="4dp" 

        android:layout_weight="1">

    </ListView>

    <LinearLayout 

         android:id="@+id/budgetLT"

         android:orientation="horizontal"

            android:layout_width="match_parent" 

            android:layout_height="70sp" > 

     </LinearLayout>

Android学习—解决ListView部分内容被Tabhost遮盖问题

重新设置后,滚动条明显b变长了,下方被遮盖的也显示出来了,问题解决~~~

不过在代码那边我也有做处理,为了是让这个界面适用不同的oncreate入口,就需要判断隐藏或显示listview下方的布局,这里就不贴代码了,定义一个全局静态变量,控制LinearLayout显示或隐藏就ok了。