huo*_*ong 6 android listview scrollview android-linearlayout
我知道,每个人的建议我们不应该使用ListView和ScrollView在一起,我完全同意.但是,我目前仍然使用一个非常简单的模式,如8tracks的个人资料页面(如下图所示),其中包括用户个人资料的区域和他们制作的混音列表.所以基本上,用户可以只向下滚动该页面,这意味着配置文件部分将在屏幕顶部逐渐退出视图,同时滚动下面的列表:

但是,目前我所能做的就是在a ListView中加入一个LinearLayout,就像我的草图一样.

通过这种设计,我只能向下滚动列表,而配置文件区域保持在相同的位置,这很糟糕.所以我正在寻找任何想法使整个页面可滚动,而不仅仅是列表.请帮助和谢谢.
编辑:我很抱歉这个误导性的问题.我的问题更加复杂,因为标签的内容不仅仅是ListView- 某些标签包含LinearLayout或GridView代替.同样,我想要实现的是使整个页面可滚动,但ScrollView无法帮助,因为如果选项卡的内容是ListView或GridView,这些视图将被折叠,更重要的是 - 这违反了设计规则.
我知道现在已经晚了,但我是 8tracks 的当前开发人员。您上面显示的(旧)2.x 应用程序正在被重写,但我可以向您展示旧开发人员对个人资料页面做了什么。
\n\n在讨论之前,我必须说这不是最好的方法,但 8tracks 应用程序 (2.x) 已经很旧了。
\n\n所以回到代码\xe2\x80\xa6\nProfileActivity包含一个ProfileFragment.
您通过“关注”按钮(和个人资料图片)看到的主要布局是这样的:
\n\n<?xml version="1.0" encoding="utf-8"?>\n<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\n android:layout_width="match_parent"\n android:layout_height="match_parent"\n android:orientation="vertical" >\n\n <!-- Image, name, location -->\n\n <RelativeLayout\n android:layout_width="match_parent"\n android:layout_height="wrap_content"\n android:orientation="horizontal"\n android:padding="10dip" >\n\n <com.gdub.widget.ImageViewClickable\n android:id="@+id/dj_avatar"\n android:layout_width="110dip"\n android:layout_height="110dip"\n android:layout_marginRight="10dip"\n android:background="@drawable/default_avatar_max200"\n android:scaleType="centerCrop" />\n\n <com.gdub.widget.CollapsingTextView\n android:id="@+id/dj_location"\n style="@style/mix.counts"\n android:layout_width="wrap_content"\n android:layout_height="wrap_content"\n android:layout_marginBottom="10dip"\n android:layout_toRightOf="@id/dj_avatar" />\n\n <ViewSwitcher\n android:id="@+id/profile_action_btn"\n android:layout_width="match_parent"\n android:layout_height="wrap_content"\n android:layout_below="@id/dj_location"\n android:layout_toRightOf="@id/dj_avatar" >\n\n <Button\n android:id="@+id/follow_btn"\n style="@style/white_button"\n android:layout_width="wrap_content"\n android:layout_height="wrap_content"\n android:text="@string/follow" />\n\n <Button\n android:id="@+id/edit_profile_btn"\n style="@style/white_button"\n android:layout_width="wrap_content"\n android:layout_height="wrap_content"\n android:text="@string/edit_profile" />\n </ViewSwitcher>\n </RelativeLayout>\n\n <TextView\n android:id="@+id/dj_bio"\n android:layout_width="match_parent"\n android:layout_height="wrap_content"\n android:layout_marginBottom="-25dip"\n android:gravity="left|center_vertical"\n android:lineSpacingExtra="2dip"\n android:paddingLeft="10dip"\n android:paddingRight="10dip"\n android:textColor="@color/default_text"\n android:textSize="15sp" />\n\n <include\n android:id="@+id/profile_tabs"\n layout="@layout/profile_tabs" />\n\n</LinearLayout>\nRun Code Online (Sandbox Code Playgroud)\n\n和 profile_tabs\xe2\x80\xa6
\n\n<?xml version="1.0" encoding="utf-8"?>\n<LinearLayout\n xmlns:android="http://schemas.android.com/apk/res/android"\n android:layout_width="match_parent"\n android:layout_height="wrap_content"\n android:visibility="gone"\n android:orientation="horizontal">\n\n <include\n android:id="@+id/profile_mixes_button"\n layout="@layout/profile_tab" />\n\n <include\n android:id="@+id/profile_followers_button"\n layout="@layout/profile_tab" />\n\n <include\n android:id="@+id/profile_following_button"\n layout="@layout/profile_tab" /> \n\n</LinearLayout>\nRun Code Online (Sandbox Code Playgroud)\n\n正如您所看到的,它是一个常规布局,带有三个“模拟”选项卡按钮。
\n\n选项卡的内容也由 ViewSwitcher 决定:
\n\n<?xml version="1.0" encoding="utf-8"?>\n<ViewSwitcher xmlns:android="http://schemas.android.com/apk/res/android"\n android:id="@+id/profile_view_switcher"\n android:layout_width="match_parent"\n android:layout_height="match_parent"\n android:inAnimation="@anim/fade_in_300"\n android:outAnimation="@anim/fade_out_300"\n android:background="@color/white">\n\n<include\n android:id="@+id/profile_loading"\n layout="@layout/loading_view_full" />\n\n<ListView\n android:id="@+id/profile_content_list"\n android:layout_width="match_parent"\n android:layout_height="match_parent"\n android:cacheColorHint="#00000000"\n android:divider="@null"\n android:dividerHeight="0dip"\n android:fadingEdge="none" />\n\n</ViewSwitcher>\nRun Code Online (Sandbox Code Playgroud)\n\n这显示了一个装载轮,然后切换到列表视图。没有其他可滚动的 ViewGroup。
\n\n基本上就是这样。
\n\n现在,如果您想让整个内容滚动,那么您需要使用自定义适配器并将上述布局设置为标题(或者至少以巧妙的方式在适配器中使用 getItemType)。这样整个屏幕就是一个列表(具有列表的所有优化)。
\n\n我们(ab)在 dev 下的新 8tracks 应用程序中使用它。;)
\n| 归档时间: |
|
| 查看次数: |
3369 次 |
| 最近记录: |