Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – Widget中的ListView GridView大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要为2部分创建一个小部件(用于主屏幕):第一个 – 顶部的ListView,它必须填充50%的小部件,第二个部分是GridView,它必须在第一个部分之下,同样必须占据50%的位置.

我试着找一些教程,但不能这样,如果有人这样做,请帮助我.

解决方法

你在谈论一个简单的布局吗? Android中的“widget”一词有多种含义.如果你的意思是布局,你可以使用LinearLayout的android:layout_weight属性为每个分配50%的空间.

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:orientation="vertical" />

    <ListView
        android:id="@+id/my_listview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1" />

    <GridView
        android:id="@+id/my_gridview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1" />

</LinearLayout>

大佬总结

以上是大佬教程为你收集整理的android – Widget中的ListView GridView全部内容,希望文章能够帮你解决android – Widget中的ListView GridView所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。