美好的一天(或傍晚或夜晚) 我正在開發針對android的應用程序,我對一件事情非常好奇。我有一個活動,用戶與另一個用戶聊天,比如「即時通訊」聊天。底部有一個EditText,頂部有一個ActionBar。我需要的是,當用戶輸入消息並且屏幕上顯示軟件鍵盤時,我的活動應該向上移動,但操作欄仍然應該「粘」到屏幕的頂部,因爲它有一些有價值的控件。 同樣,這不是一個ActionBar,而是一個父級垂直線性佈局中的48dp高度佈局。所以我需要知道是否有一種簡單的方法可以防止佈局移出屏幕時移動到頂端。 我試圖把一切都放在一個FrameLayout裏和放在它上面這個酒吧,但鍵盤上的AndroidManifest打開它熄滅屏幕太...狀態欄始終顯示在屏幕上
1
A
回答
0
在你的活動,你應該把這樣的:機器人:windowSoftInputMode =」 adjustResize」
0
使用這樣的事情:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.myapp.MyActionBar
android:layout_width="match_parent"
android:layout_height="48dp"/>
<LinearLayout
android:id="@+id/mylayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1dp"/>
<!-- Add your edittext and button -->
</LinearLayout>
這將確保在動作條和的EditText +按鈕是百達在屏幕上,而mylayout
佔據了屏幕的其餘部分。顯示鍵盤時,mylayout
會縮小。
0
嘗試爲清單中的活動添加android:windowSoftInputMode =「adjustResize」。這告訴Android在鍵盤出現時完全調整您的佈局,而不是平移它。請注意,如果整個佈局沒有足夠的空間,這仍然無法工作。但是如果你的頂層佈局是一個RelativeLayout,你應該能夠使它工作,編輯文本設置爲對齊底部,頂部欄對齊頂部,中間部分爲fill_parent並且位於編輯文本的上方,酒吧。
0
使用的RelativeLayout爲您的基地佈局,並添加機器人:layout_alignParentTop =「true」以你的動作條,以保持它
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/action_bar_layout"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentTop="true" >
</LinearLayout>
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
相關問題
- 1. 始終顯示狀態欄和軟鍵
- 2. 如何設置鍵盤始終顯示在屏幕上?
- 3. GNU屏幕命令不顯示狀態欄
- 4. 原始圖像在屏幕上顯示
- 5. iPhone6狀態欄顯示放大的應用程序,但不在主屏幕上
- 6. 如何在LibGDX上顯示狀態欄?
- 7. 服務啓動器狀態始終顯示在macOS上停止
- 8. 如何讓應用始終在屏幕上保持活躍狀態
- 9. BlackBerry - 狀態欄重疊屏幕
- 10. 屏幕鎖定時的狀態欄android
- 11. UIScreen屏幕始終返回1屏幕
- 12. 在屏幕上顯示textView
- 13. 在屏幕上顯示
- 14. 元素始終顯示在分段屏幕的頂部。問題
- 15. 在主屏幕上隱藏Android狀態欄
- 16. Android的 - 在它上面製作活動全屏幕狀態欄
- 17. 標籤欄顯示在屏幕外
- 18. GNU屏幕:如何在按下命令字符時突出顯示狀態欄
- 19. 在顯示狀態欄之前獲取高度狀態欄?
- 20. 隱藏/顯示狀態欄
- 21. 狀態欄庫不顯示
- 22. 初始屏幕不顯示在android
- 23. 如何隱藏飛濺/啓動屏幕上的狀態欄(鈦)
- 24. UWP應用如何在全屏顯示狀態欄?
- 25. 當全屏顯示控制器時,狀態欄回顯(可見)
- 26. 顯示有關狀態欄上連接狀態的信息
- 27. 操作欄菜單顯示屏幕
- 28. 如何在鎖定屏幕控件上顯示搜索欄
- 29. 在小屏幕上顯示全導航欄
- 30. Bootstrap導航欄崩潰但不會顯示在大屏幕上