我在活動中有一個頁腳。這個頁腳包含。在edittext下面放置一個edittext和一個radiogroup。幾乎像頁腳頁腳。 基本上我使用radiogroup來選擇鍵盤類型(表情符號鍵盤或普通鍵盤)。 xml在下面。帶腳註的editdtext。當edittext獲得焦點時,腳本在softinputkeyboard下消失
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textbase_layout"
android:background="@color/appwhite">
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@color/window_background"
android:layout_alignParentTop="true" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxHeight="80dp"
android:id="@+id/comment_txt"
android:layout_marginTop="8dp"
android:textColorHint="@color/comment_header_grey"
android:hint="message goes here"
android:background="@android:color/transparent"
android:padding="5dp"
android:focusable="true"
android:layout_marginLeft="10dp"
android:layout_centerVertical="true"
android:layout_marginRight="10dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/appwhite"
android:layout_below="@id/textbase_layout">
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:orientation="horizontal">
<RadioButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/keyboard_btn"
android:padding="8dp"
android:textColor="@drawable/selector_text_radio"
android:button="@drawable/keyboard_icon_selector"
android:layout_marginRight="5dp" />
<RadioButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/emoji_btn"
android:padding="8dp"
android:textColor="@drawable/selector_text_radio"
android:button="@drawable/smiley_icon_selector"
android:layout_marginLeft="5dp" />
</RadioGroup>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/send_btn"
android:text="Send"
android:textColor="@color/bcg_blue"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@android:color/transparent" />
</RelativeLayout>
</RelativeLayout>
我有WindowSoftInputMode = SoftInput.AdjustResize set也。當我選擇edittext時,我希望整個頁腳都被推上去。包括radiogroup。但在某些情況下,這不會發生。底部的radiogroup正在被軟鍵盤切斷。當我在我的oncreate()方法中執行這一行時。
Window.SetSoftInputMode(SoftInput.StateAlwaysHidden);
如果我註釋掉上面的行。該radiogroup總是顯示,但它創造了一個不同的不受歡迎的條件,因爲當第一次打開活動時軟鍵盤會彈出。 在這種情況下,我試圖從edittext中移除焦點,但softkeyboard在進入活動時仍然彈出。如果任何人有任何想法如何解決這個問題,將不勝感激。
當顯示鍵盤時,android只會推動直到焦點處的控件。您的單選按鈕是佈局中的單獨控件,它們不會被推到鍵盤上。您可能想要使用編輯控件左側的切換按鈕,就像大多數聊天應用程序用於更改鍵盤類型一樣。 – chejaras