我知道这是晚了,但我对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" >
<!-- Image, name, location -->
<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。
而这基本上它。
现在,如果您希望滚动WHOLE事物,那么您需要使用自定义适配器并将上述布局设置为标题(或至少在适配器中以巧妙的方式使用getItemType)。这样整个屏幕就是一个List(包含一个列表的所有优化)。
我们(AB)下开发新的应用程序8tracks使用此。 ;)
从作者那里得到答案真棒!这太聪明了,我真的很感激它。虽然我已经完成了我的项目(通过放弃使用标题部分),但我相信这对未来(以及其他人也是如此)将对我有用。)非常感谢。 – 2013-11-17 03:36:18
不客气! :) – 2013-11-17 08:29:28