BottomSheet 焦点问题
BottomSheet focus issue
我在 Android 中使用了 BottomSheet,其中包含一个 MapView 和一个用于搜索数据的 EditText。
现在,在 SoftKeyboard 未打开之前,Map 和 BottomSheet 行为可以正常工作,即 Map 像 charm 一样滚动。
问题 是当 SoftKeyboard 打开时,我试图通过一些硬滚动从上到下滚动地图,BottomSheet 关闭(状态为隐藏)这不是在SofKeyboard未打开的情况下。
在向下滚动地图时避免 BottomSheet 关闭的解决方案是什么而 SofeKeyboard 是打开的。
谢谢。
编辑
包含 BottomSheet 的布局如下所示,其中包含 TabLayout,其中包含三个片段,地图在第一个片段中:
<?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"
android:id="@+id/parentView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:focusableInTouchMode="true" >
<RelativeLayout
android:id="@+id/rltBottomSheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="true"
android:paddingTop="@dimen/size_10"
app:layout_behavior="@string/view_pager_bottom_sheet_behavior">
<include layout="@layout/view_bottom_sheet_bg" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:clickable="true">
<RelativeLayout
android:id="@+id/rltHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imgBackAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="@dimen/size_10"
android:padding="@dimen/size_15"
android:src="@drawable/ic_back_all" />
<ImageView
android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/size_10"
android:padding="@dimen/size_5"
android:src="@drawable/ic_add_gym" />
</RelativeLayout>
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/imgLogo"
android:minHeight="?attr/actionBarSize"
app:tabGravity="fill"
app:tabIndicatorColor="@color/tab_indicator_color"
app:tabIndicatorHeight="@dimen/size_2"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/explore_tab_text_color"
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
app:tabTextColor="@color/explore_tab_text_color" />
<android.support.v4.view.ViewPager
android:id="@+id/vp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/tabLayout" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_alignParentBottom="true"
android:alpha="0.5"
android:background="@drawable/ic_bottom_overlay"
android:visibility="gone"/>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
将 MapView
的根设为 NestedScrollView
。
<android.support.v4.widget.NestedScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent">
// Your content goes here
</android.support.v4.widget.NestedScrollView>
我在 Android 中使用了 BottomSheet,其中包含一个 MapView 和一个用于搜索数据的 EditText。
现在,在 SoftKeyboard 未打开之前,Map 和 BottomSheet 行为可以正常工作,即 Map 像 charm 一样滚动。
问题 是当 SoftKeyboard 打开时,我试图通过一些硬滚动从上到下滚动地图,BottomSheet 关闭(状态为隐藏)这不是在SofKeyboard未打开的情况下。
在向下滚动地图时避免 BottomSheet 关闭的解决方案是什么而 SofeKeyboard 是打开的。
谢谢。
编辑
包含 BottomSheet 的布局如下所示,其中包含 TabLayout,其中包含三个片段,地图在第一个片段中:
<?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"
android:id="@+id/parentView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:focusableInTouchMode="true" >
<RelativeLayout
android:id="@+id/rltBottomSheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="true"
android:paddingTop="@dimen/size_10"
app:layout_behavior="@string/view_pager_bottom_sheet_behavior">
<include layout="@layout/view_bottom_sheet_bg" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:clickable="true">
<RelativeLayout
android:id="@+id/rltHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imgBackAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="@dimen/size_10"
android:padding="@dimen/size_15"
android:src="@drawable/ic_back_all" />
<ImageView
android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/size_10"
android:padding="@dimen/size_5"
android:src="@drawable/ic_add_gym" />
</RelativeLayout>
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/imgLogo"
android:minHeight="?attr/actionBarSize"
app:tabGravity="fill"
app:tabIndicatorColor="@color/tab_indicator_color"
app:tabIndicatorHeight="@dimen/size_2"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/explore_tab_text_color"
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
app:tabTextColor="@color/explore_tab_text_color" />
<android.support.v4.view.ViewPager
android:id="@+id/vp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/tabLayout" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_alignParentBottom="true"
android:alpha="0.5"
android:background="@drawable/ic_bottom_overlay"
android:visibility="gone"/>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
将 MapView
的根设为 NestedScrollView
。
<android.support.v4.widget.NestedScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent">
// Your content goes here
</android.support.v4.widget.NestedScrollView>