编辑:我需要使用键盘,但是它遮住了我的EditText
,我需要它滚动以使键盘不再遮挡它。
我正在使用三星平板电脑。
我的样式:
parent="android:Theme.Holo.NoActionBar.Fullscreen"
EditText
字段位于可滚动的视图中,如下所示:片段布局:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<ScrollView
android:layout_height="wrap_content"
android:layout_width="match_parent">
<LinearLayout
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:layout_width="match_parent"
android:orientation="vertical">
<TextView
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:text="@string/depot_code"/>
<EditText
android:hint="@string/enter_depot_code"
android:id="@+id/etlocationId"
android:imeOptions="actionNext"
android:inputType="number"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:lines="1"
android:maxLength="12"
android:singleLine="true">
<requestFocus/>
</EditText>
<TextView
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:text="@string/name"/>
<EditText
android:hint="@string/enter_name"
android:id="@+id/etname"
android:imeOptions="actionNext"
android:inputType="textPersonName"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:lines="1"
android:maxLength="24"
android:singleLine="true"/>
<TextView
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:text="@string/street"/>
<EditText
android:hint="@string/enter_street"
android:id="@+id/etstreet"
android:imeOptions="actionNext"
android:inputType="textPostalAddress"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:lines="1"
android:maxLength="24"
android:singleLine="true"/>
<TextView
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:text="@string/suburb"/>
<EditText
android:hint="@string/enter_suburb"
android:id="@+id/etsuburb"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:lines="1"
android:maxLength="24"
android:singleLine="true"/>
<TextView
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:text="@string/state"/>
<Spinner
android:focusable="true"
android:focusableInTouchMode="true"
android:id="@+id/spinner"
android:imeOptions="actionNext"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="fill_parent"
android:spinnerMode="dropdown"/>
<TextView
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:text="@string/phone"/>
<EditText
android:hint="@string/enter_phone"
android:id="@+id/etphone"
android:imeOptions="actionDone"
android:inputType="phone"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:lines="1"
android:maxLength="12"
android:singleLine="true"/>
<Button
android:id="@+id/btnadd"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:text="@string/add"/>
</LinearLayout>
</ScrollView>
</FrameLayout>
活动布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tech_controller"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
< .../ Layouts. ../>
<FrameLayout
android:id="@+id/second"
android:layout_height="match_parent"
android:layout_width="fill_parent"/>
</LinearLayout>
有类似的问题被问到过,但我没有找到一个有效的答案。
我的项目中有很多片段与一个活动连接在一起。在活动的清单中,我有:
android:windowSoftInputMode="stateHidden"
其中一些片段需要用户输入。
在片段布局中,我使用:
每个片段嵌套如下:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent" .../>
<ScrollView
android:layout_height="match_parent"
android:layout_width="match_parent">
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">
<EditText
android:imeOptions="actionNext"
or
android:imeOptions="actionDone" .../>
除了键盘会遮挡页面下方的EditTexts,这段代码效果很好。
我已经反复阅读过以下内容:
http://developer.android.com/reference/android/widget/TextView.html#attr_android:imeOptions
尝试了这些建议,但是当调用活动时键盘仍然可见,而我不想要这个。它也不起作用。也许因为它是一个片段?
Android Keyboard hides EditText
我一直在尝试找到一种动态解决方案。感谢任何帮助。
编辑:这是用于平板电脑的,并且只有一种键盘选项,带有语言更改。
编辑:我的解决方案
我通过安装另一个软键盘来解决它。https://code.google.com/p/softkeyboard/wiki/HowTo
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
标志或其他标志来全屏显示你的活动? - Lalit PoptanionCreate()
中清除标志,使用getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
。 - Lalit Poptani