![](/img/trans.png)
[英]android:windowSoftInputMode=“adjustResize” had slow resize
[英]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>
已編輯
發現奇怪的行為。 我有自定義的horizontalscrollview作為父級和兩個子級: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.