激活键盘时上推片段内容 [英] Push Up Fragment content when keyboard is activated
本文介绍了激活键盘时上推片段内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经搜索了所有内容,然后将所有内容包装在ScrollView中,并以这种方式设置键盘:
I've searched it everywhere, and I've come up wrapping all my content inside a ScrollView, and setting the keyboard this way:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
但是当我通过点击EditText启用键盘时,除了顶部的TextView之外,所有内容都被上推了,为什么?
But when I enable the keyboard by tapping the EditText, all the content gets pushed up except for a TextView in the Top part, why is that?
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.FET.leonardo.scurcola.NameSelection"
android:background="#e0ab18">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/whoMaster"
android:textColor="@color/white"
android:textSize="50sp"
android:layout_marginTop="50dp"
android:textAlignment="center"
android:id="@+id/whoMaster"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:hint="@string/master"
android:ems="10"
android:textColorHint="@color/white"
android:textColor="@color/white"
android:textColorHighlight="@color/white"
android:id="@+id/names"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/next"
android:layout_marginBottom="50dp"
android:onClick="onClick"
android:text="@string/next"
android:layout_alignParentBottom="true"
android:layout_alignEnd="@+id/names"
android:textColor="#e0ab18" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/back"
android:id="@+id/back"
android:enabled="false"
android:onClick="onClick"
android:textColor="#e0ab18"
android:layout_marginBottom="50dp"
android:layout_alignParentBottom="true"
android:layout_alignStart="@+id/names" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/finish"
android:visibility="gone"
android:text="@string/finish"
android:layout_alignParentBottom="true"
android:layout_alignEnd="@+id/names"
android:layout_marginBottom="50dp"
android:onClick="onClick"
android:textColor="#e0ab18"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/zero"
android:textSize="50sp"
android:textColor="@color/white"
android:id="@+id/playersLeft"
android:layout_below="@+id/names"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp" />
</RelativeLayout>
推荐答案
在滚动视图之后尝试使用线性布局,而不是RelativeLayout.将方向"设置为垂直".
Instead of RelativeLayout try to use Linear Layout after scrollView.Set Orientation to Vertical.
这篇关于激活键盘时上推片段内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文