我有一個活動CoordinatorLayout工具欄不隱藏在回收視圖滾動
public class ResourceListActivity extends AppCompatActivity {
private ActivityResourceListBinding mBinding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_resource_list);
getWindow().setStatusBarColor(ContextCompat.getColor(getBaseContext(), R.color.colorPrimary));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setElevation(0f);
RecommendResourceFragment fragment = RecommendResourceFragment.newInstance(mColumnCount);
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.container_main, fragment);
fragmentTransaction.commit();
}
}
佈局文件是:activity_resource_list.xml
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="in.securelearning.lil.android.resources.view.activity.ResourceListActivity">
<RelativeLayout
android:id="@+id/container_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorWhite"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</LinearLayout>
</layout>
而且RecommendResourceFragment.java片段編排如下:
<layout>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="4dp"
android:background="@color/colorPrimary"
app:layout_collapseMode="parallax"
app:tabGravity="fill"
app:tabMode="scrollable"/>
<android.support.v4.view.ViewPager
android:id="@+id/resourcePager"
android:layout_width="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_height="match_parent"/>
</android.support.design.widget.CoordinatorLayout>
</layout>
而在每個頁面下面的佈局是嵌入水平標籤呈現。
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorBackground"
android:orientation="vertical">
<HorizontalScrollView
android:id="@+id/hlistview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none">
<LinearLayout
android:id="@+id/imageview_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
</LinearLayout>
</HorizontalScrollView>
<FrameLayout
android:id="@+id/list_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
<android.support.v7.widget.RecyclerView
android:id="@+id/video_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:alwaysDrawnWithCache="true"
android:animationCache="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:drawingCacheQuality="high"
app:layout_collapseMode="parallax"
android:scrollbars="vertical">
</android.support.v7.widget.RecyclerView>
<LinearLayout
android:id="@+id/layoutBottomProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="gone">
<ProgressBar
android:id="@+id/progressBarBottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<in.securelearning.lil.android.base.widget.TextViewCustom
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Hold on !\nLoading more videos..."
android:textSize="16sp"
android:visibility="gone"/>
</LinearLayout>
<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
</FrameLayout>
<LinearLayout
android:id="@+id/layoutNoResult"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal|center_vertical"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/logo_assignment" />
<in.securelearning.lil.android.base.widget.TextViewCustom
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/string_no_results_found"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
</layout>
我已經申請程序:layout_behavior = 「@字符串/ appbar_scrolling_view_behavior」 在每一個階段,但工具欄不隱藏。 任何建議。提前致謝。
我不使用自定義工具欄到工具欄。所以不可能添加建議的行。 – Teekam
@Teekam你可以使用它默認 –
請解釋如何? – Teekam