繁体   English   中英

android windowSoftInputMode不调整布局大小

[英]android windowSoftInputMode doesnt resize layout

我有一个ActivityGroup。 hild活动具有一组EditText。 当出现虚拟键盘时,布局不会向上移动,并且用户看不到输入字段。 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>

已编辑

发现奇怪的行为。 我有自定义的horizo​​ntalscrollview作为父级和两个子级:activityGroup和listview。 当删除scrollview并将activitygroup设置为parent时,一切正常。

我可以建议您将布局放在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>

对我来说唯一要做的就是在代码中

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

进入我的活动的onCreate方法。

所有XML尝试都根本不起作用,尽管我听说有些骇客似乎可以通过在android:windowSoftInputMode设置多个状态值来在某些设备上android:windowSoftInputMode ,这显然有点android:windowSoftInputMode ,因为Google 在这里指出这可能会导致“ 未定义的结果 ”。

无论如何,以上行在到目前为止我尝试过的每台设备上都运行良好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM