我有一个ActivityGroup。 СhildActivity有一组EditText。当出现虚拟键盘时,布局不会向上移动,用户无法看到输入字段。
在android:windowSoftInputMode="adjustResize"
中设置manifest.xml
并未提供所需的结果。
<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
发现奇怪的行为。我有自定义horizontalscrollview作为父和两个孩子:activityGroup和listview。删除scrollview并将activitygroup设置为parent时,所有工作正常。
答案 0 :(得分:0)
我建议您将布局放在 ScrollView 中,然后在清单中添加
android:windowSoftInputMode="adjustResize"
。
这样的事情
<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>
答案 1 :(得分:0)
对我来说唯一能做到的就是在代码中完成它,通过放
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
进入我的onCreate
方法。
所有的XML尝试根本不起作用,虽然我已经听说过某些设备似乎在某些设备上工作,但在android:windowSoftInputMode
中设置了多个状态值,这显然是一个黑客攻击here这可能导致&#34; 未定义的结果&#34;。
无论如何,上面一行在我到目前为止尝试过的每台设备上运行良好。