我正在尝试使用CoordinatorLayout和CollapsingToolbar和SoftInputMode。当我尝试在Coordinator布局中使用android:fitsSystemWindows =“ false”时。它运作良好。但是,SoftInputMode无法正常工作。这意味着当EditText处于活动状态时,布局必须调整大小。我向清单文件中添加了SOftInputMode。但是,它不起作用。
问题是当android:fitsSystemWindows =“ false”,状态栏背景不起作用时。但是,布局调整大小效果很好。
类似地,当android:fitsSystemWindows =“ true”时,状态栏背景也可以正常工作。但是,布局调整大小无法正常工作。
我的Layout代码是
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:statusBarBackground="@color/myCustomColor"
android:theme="@style/AppThemeCorrdinate"
android:fitsSystemWindows="false"
tools:context="com.uiresource.messenger.Conversation">
<android.support.design.widget.AppBarLayout
android:id="@+id/htab_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/my_gradient_bg"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay"
app:expanded="false">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsetoolbar"
android:layout_width="match_parent"
android:layout_height="330dp"
android:fitsSystemWindows="true"
app:contentScrim="@drawable/my_gradient_bg"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
app:titleEnabled="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.app.FragmentTabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
<FrameLayout
android:id="@+id/realTabContent"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
</android.support.v4.view.ViewPager>
</LinearLayout>
<TabWidget
android:id="@android:id/tabs"
style="@style/MyTabStyle"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="bottom"
android:layout_weight="0"
android:orientation="horizontal"
android:showDividers="none"
android:visibility="gone" />
</android.support.v4.app.FragmentTabHost>
</LinearLayout>
<HorizontalScrollView
android:id="@+id/chipscrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:fitsSystemWindows="true"
android:scrollbars="none">
<RadioGroup
android:id="@+id/radiogroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:scrollbars="none">
</RadioGroup>
</HorizontalScrollView>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0"
android:background="@android:color/black"
android:fitsSystemWindows="true"
app:layout_collapseParallaxMultiplier="1.0" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="top"
android:layout_marginBottom="0dp"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="@drawable/user1" />
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:gravity="center"
android:textAllCaps="false"
android:textAppearance="@style/Light"
android:textColor="@android:color/white"
android:textSize="@dimen/h1" />
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/htab_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:visibility="gone"
app:tabIndicatorColor="@android:color/white"
app:tabSelectedTextColor="@android:color/white"
app:tabTextColor="@color/white" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/add_to_cart_fab2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:src="@android:drawable/ic_menu_save"
android:visibility="gone"
app:layout_anchor="@id/toolbar"
app:layout_anchorGravity="bottom|right" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/add_to_cart_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:src="@android:drawable/ic_menu_save"
android:visibility="gone"
app:layout_anchor="@id/htab_appbar"
app:layout_anchorGravity="bottom|center" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/root_layout"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:fillViewport="true"
>
<RelativeLayout
android:id="@+id/rootView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/rl_bottom">
<LinearLayout
android:id="@+id/layout_rvh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/chaty_bg"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:clipToPadding="false"
android:overScrollMode="never"
android:paddingTop="8dp"
android:paddingBottom="20dp" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/rl_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:fitsSystemWindows="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">
<HorizontalScrollView
android:id="@+id/hsv_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@color/white"
android:gravity="bottom"
android:scrollbars="none"
android:visibility="visible">
<LinearLayout
android:id="@+id/chat_quick_area"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<include
layout="@layout/rich_replies_card"
android:visibility="visible" />
</LinearLayout>
</HorizontalScrollView>
<RelativeLayout
android:id="@+id/editContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/hsv_content"
android:background="#E9EDED"
android:paddingLeft="@dimen/space10"
android:paddingTop="@dimen/space5"
android:paddingRight="@dimen/space5"
android:paddingBottom="@dimen/space5">
<ImageButton
android:id="@+id/bt_send"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:background="@drawable/bg_btnsend_rounded"
android:gravity="center"
android:padding="@dimen/space5"
android:src="@drawable/baseline_send_white_36"
android:stateListAnimator="@null"
android:textAppearance="@style/Light"
android:textColor="@color/white"
android:textSize="@dimen/h3" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/space5"
android:layout_toLeftOf="@id/bt_send"
android:background="@drawable/bg_white_rounded">
<ImageButton
android:id="@+id/bt_attachment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="@android:color/transparent"
android:padding="@dimen/space10"
app:srcCompat="@drawable/ic_attachment" />
<EditText
android:id="@+id/et_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/bt_attachment"
android:background="@android:color/transparent"
android:hint="Enter your message"
android:inputType="textCapSentences"
android:maxLines="3"
android:padding="@dimen/space10"
android:textAppearance="@style/ThemeOverlay.AppCompat.Dark"
android:textColor="@color/colorTextBlack"
android:textColorHint="@color/colorTextHint"
android:textSize="@dimen/h2" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone"
android:gravity="bottom">
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
答案 0 :(得分:0)
1.remove android:fitsSystemWindows =“ false”,因为它可能导致布局滚动。在Android 4.x上 2.通过设置样式来更改状态栏颜色。