[英]android windowSoftInputMode doesnt resize layout
I have an ActivityGroup. 我有一个ActivityGroup。 Сhild Activity has a set of EditText(s).
hild活动具有一组EditText。 When a virtual keyboard appears, the layout does not moves up and user can't see an input field.
当出现虚拟键盘时,布局不会向上移动,并且用户看不到输入字段。 Setting
android:windowSoftInputMode="adjustResize"
in manifest.xml
doesn't give required result. 在
manifest.xml
中设置android:windowSoftInputMode="adjustResize"
不会提供所需的结果。
<activity android:name="com.boyko.organizer.activities.editors.AddCarActivity" android:windowSoftInputMode="adjustResize" >
</activity>
<activity android:name="MainActivityGroupWithFrame" android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
EDITED 已编辑
Found strange behavior. 发现奇怪的行为。 i have custom horizontalscrollview as a parent and two childs: activityGroup and listview.
我有自定义的horizontalscrollview作为父级和两个子级:activityGroup和listview。 When remove scrollview and set activitygroup as parent, than all works fine.
当删除scrollview并将activitygroup设置为parent时,一切正常。
What I can suggest you is put your layout in ScrollView and then in the manifest add android:windowSoftInputMode="adjustResize"
. 我可以建议您将布局放在ScrollView中 ,然后在清单中添加
android:windowSoftInputMode="adjustResize"
。 Somthing like this 这样的事情
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/tv_message"
style="@style/Text.Large.Bold.Colored.Red" />
// other widget
</LinearLayout>
</ScrollView>
The only thing that did it for me was doing it in code, by putting 对我来说唯一要做的就是在代码中
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
into my activity's onCreate
method. 进入我的活动的
onCreate
方法。
All XML attempts did not work at all, although I have heard of some hacks that seem to work at some devices by setting more than one state value in android:windowSoftInputMode
which is obviously a bit of a hack since Google states here this might lead to " undefined results ". 所有XML尝试都根本不起作用,尽管我听说有些骇客似乎可以通过在
android:windowSoftInputMode
设置多个状态值来在某些设备上android:windowSoftInputMode
,这显然有点android:windowSoftInputMode
,因为Google 在这里指出这可能会导致“ 未定义的结果 ”。
Anyways the line above worked fine on every device I have tried so far. 无论如何,以上行在到目前为止我尝试过的每台设备上都运行良好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.