我有一个活动,其布局内容如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
style="@style/ToolBarStyle.Event" />
<com.mypackage.corecode.ui.view.SlidingTabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primary_color" />
<android.support.v4.view.ViewPager
android:id="@+id/vendor_main_tabview_pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
在ViewPager中,我有一个Fragment,该Fragment具有以下布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3"
android:orientation="horizontal">
<EditText
android:theme="@style/ScrollableContentThemeNoActionBar"
android:id="@+id/edit_text_vendor_sms_phone_number"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:inputType="number" />
<Button
android:id="@+id/button_send_sms"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
当碎片内的内容不适合屏幕时,滚动视图允许用户查看屏幕下方的内容。(正常工作)
问题是当edittext获得焦点时,键盘会覆盖edittext区域,而不是滚动视图导致内容滚动。
我希望该片段处理键盘显示并使滚动视图适应屏幕上的键盘。
或者我错了,键盘是由活动负责的吗?由于活动布局中的根视图是线性布局,它限制了扩展吗?
我尝试将活动布局的整个内容都用滚动视图包装起来,但这一次,如果我没有给它一个固定的大小,viewpager就不会出现在屏幕上。 即使我这样做了,我最终还是在主布局的滚动视图下有一个碎片内的滚动视图,而键盘仍然悬浮在edittext上面。
我有点迷茫了,我的目标是当edittext获得焦点时能够滚动片段内容,但目前键盘却遮挡了edittext。
android:windowSoftInputMode="adjustResize|adjustPan"
吗? - muratgu