我知道有点晚了,但我是8tracks的现任开发者。你上面展示的(旧的)2.x应用正在被重写,但我可以向你展示旧开发人员为个人资料页面所做的工作。
在进入之前,我必须说这不是最好的方法,但8tracks应用程序(2.x)已经老旧了。
回到代码本身...
ProfileActivity
包含一个
ProfileFragment
。
你看到的主要布局包括关注按钮(和个人资料图片)如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dip" >
<com.gdub.widget.ImageViewClickable
android:id="@+id/dj_avatar"
android:layout_width="110dip"
android:layout_height="110dip"
android:layout_marginRight="10dip"
android:background="@drawable/default_avatar_max200"
android:scaleType="centerCrop" />
<com.gdub.widget.CollapsingTextView
android:id="@+id/dj_location"
style="@style/mix.counts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:layout_toRightOf="@id/dj_avatar" />
<ViewSwitcher
android:id="@+id/profile_action_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/dj_location"
android:layout_toRightOf="@id/dj_avatar" >
<Button
android:id="@+id/follow_btn"
style="@style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/follow" />
<Button
android:id="@+id/edit_profile_btn"
style="@style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/edit_profile" />
</ViewSwitcher>
</RelativeLayout>
<TextView
android:id="@+id/dj_bio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="-25dip"
android:gravity="left|center_vertical"
android:lineSpacingExtra="2dip"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:textColor="@color/default_text"
android:textSize="15sp" />
<include
android:id="@+id/profile_tabs"
layout="@layout/profile_tabs" />
</LinearLayout>
并且 profile_tabs...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:orientation="horizontal">
<include
android:id="@+id/profile_mixes_button"
layout="@layout/profile_tab" />
<include
android:id="@+id/profile_followers_button"
layout="@layout/profile_tab" />
<include
android:id="@+id/profile_following_button"
layout="@layout/profile_tab" />
</LinearLayout>
所以你可以看到这是一个常规布局,带有三个“模拟”选项卡按钮。
选项卡的内容也由ViewSwitcher确定:
<?xml version="1.0" encoding="utf-8"?>
<ViewSwitcher xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/profile_view_switcher"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inAnimation="@anim/fade_in_300"
android:outAnimation="@anim/fade_out_300"
android:background="@color/white">
<include
android:id="@+id/profile_loading"
layout="@layout/loading_view_full" />
<ListView
android:id="@+id/profile_content_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cacheColorHint="#00000000"
android:divider="@null"
android:dividerHeight="0dip"
android:fadingEdge="none" />
</ViewSwitcher>
这显示一个加载轮并切换到列表视图。没有其他可滚动的ViewGroup。
基本上就是这样。
如果您想让整个屏幕都可以滚动,则需要使用自定义适配器,并将上述布局设置为标题(或者至少在适配器中巧妙地使用getItemType)。这样整个屏幕就成为了列表(具有列表的所有优化)。
我们在正在开发的新版8tracks应用程序中(滥用)它。;)