Android 如何使AppBarLayout粘贴到布局顶部
我希望当软键盘出现时,AppBarLayout会停留在屏幕顶部,但它总是被推离屏幕Android 如何使AppBarLayout粘贴到布局顶部,android,drawerlayout,android-appbarlayout,Android,Drawerlayout,Android Appbarlayout,我希望当软键盘出现时,AppBarLayout会停留在屏幕顶部,但它总是被推离屏幕 该活动具有android:WindowsOfInputMode=“adjustPan”(还尝试将其设置为默认值) 我已尝试在AppBarLayout(以及此属性的各种配置)上设置app:layout_scrollFlags=“scroll | enterally | snap” 我已经尝试将AppBarLayout包装在一个协调布局中,并设置了android:layout\u alignParentTop=“t
- 该活动具有android:WindowsOfInputMode=“adjustPan”(还尝试将其设置为默认值)
- 我已尝试在AppBarLayout(以及此属性的各种配置)上设置app:layout_scrollFlags=“scroll | enterally | snap”
- 我已经尝试将AppBarLayout包装在一个协调布局中,并设置了
和android:layout\u alignParentTop=“true”
,app:layout\u constraintStart\u toStartOf=“parent”
app:layou constraintBottom\u tobottomf=“parent”
使用以下代码:
1.首先为AppBarLayoutandroid:id=“@+id/text1”设置id,然后在AppBarLayoutandroid:layout\u=“@+id/text1”下方设置FrameLayout
我添加了id,将下面的
布局规则添加到框架布局
,并尝试将其包装在相对布局
中,但没有效果。谢谢你的建议。
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_green_light"
android:fitsSystemWindows="true"
tools:openDrawer="end">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"
app:layout_scrollFlags="scroll|enterAlways|snap"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<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" />
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/colorSecondary"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:itemBackground="@drawable/drawer_menu_highlighted_item_background_color"
app:itemIconTint="@drawable/drawer_menu_highlighted_item_text_color"
app:itemTextAppearance="@style/GlobalMenuText"
app:itemTextColor="@drawable/drawer_menu_highlighted_item_text_color"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/text1"
android:theme="@style/AppTheme.AppBarOverlay"
app:layout_scrollFlags="scroll|enterAlways|snap"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<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.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/text1"/>
</RelativeLayout>