温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

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

发布时间:2020-06-08 23:16:41 来源:网络 阅读:1421 作者:孤月2012 栏目:移动开发

问题: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了。

 

 

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI