我試圖做這樣的事情:頭佈局上面TabLayout
我現在有沒有實現的頭上面的佈局。我需要的是找出如何添加標題。
這裏是頭佈局我想把上面的標籤:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_horizontal"
android:background="@color/green">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/ic_image"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:layout_gravity="center_vertical" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hey!"
android:textColor="@color/white"
android:textSize="24sp"
android:layout_gravity="center_vertical" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
我用一個RecyclerView
的標籤下面的內容。我使用3個不同的Fragments
作爲Activity
。
這裏是我的活動:
這裏是我的一個片段:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</android.support.design.widget.CoordinatorLayout>
如何添加上述TabLayout
,並保持正常的滾動行爲的頭?
FrameLayout可能對此很有用,因爲您可以將它放置在屏幕的任何位置。所以一種可能的方式來實現這一點 - 沒有工具欄,並使用framelayout,並把它想要的東西,包括其他佈局,把它放在你想要的位置,並在它下面的表格 – Tasos
只有屏幕的內容部分滾動與您的建議。 :/ – user5314557
檢查這個庫 https://github.com/noties/Scrollable – orium