我正在使用CoordinateLayout
,其中AppBarLayout
及以下ScrollView
, AppbarLayout
和ScrollView
是互相重叠的。如何将下面的ScrollView设置为AppBarLayout。让我知道谢谢
<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:background="@drawable/bg_blue"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/padding_medium"
android:layout_marginRight="@dimen/padding_medium"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/padding_verysmall"
android:gravity="center"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
</android.support.design.widget.CoordinatorLayout>
最佳答案
像这样添加即可
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/padding_medium"
android:layout_marginRight="@dimen/padding_medium"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/padding_verysmall"
android:gravity="center"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
</RelativeLayout>
将您的ScrollView
放入RelativeLayout
内。并在 RelativeLayout
中添加您的 Activity 或布局
上下文。
关于android - 如何在CoordinateLayout中的AppbarLayout之后添加RelativeLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39805883/