[英]How to make button stay on the bottom when soft keyboard goes up
我在屏幕底部有一個按鈕,即使軟鍵盤上升,我也希望它保持關閉狀態,但目前它會隨着軟鍵盤上升。 我試圖將按鈕與底部對齊,但沒有成功。
這是代碼(按鈕在 id/activity_form_button_frame 中):
<RelativeLayout>
<RelativeLayout
android:id="@+id/activity_form_button_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<ImageButton
android:id="@+id/activity_form_next_button"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/black"
android:src="@drawable/next_btn_drawable"
android:scaleType="fitCenter"
android:padding="5dp"
/>
<Button
android:id="@+id/activity_form_sumbit_button"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/black"
android:text="SUBMIT"
android:textColor="@color/buttonBlue"
android:visibility="gone"
android:padding="15dp"
style="@android:style/TextAppearance.Large"/>
</RelativeLayout>
<FrameLayout
android:id="@+id/activity_form_fragmentcontainer"
android:layout_below="@id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/activity_form_button_frame"/>
</RelativeLayout>
在AndroidManifest.xml
,將android:windowSoftInputMode="adjustPan"
為您的活動。
像這樣。
<activity
android:windowSoftInputMode="adjustPan">
或者:
<activity
android:windowSoftInputMode="adjustPan|adjustResize">
您也可以以編程方式執行此操作。
在
onCreate()
方法中使用此代碼:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
檢查此參考。
試試這個....
<activity
android:windowSoftInputMode="adjustPan">
試試這個
<activity
android:windowSoftInputMode="adjustPan">
或在代碼中
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
嘗試將清單添加到您的活動屬性 android:windowSoftInputMode。 將其設置為 adjustResize 或 adjustPan。 其中之一將起作用。
在您的活動標簽下的清單文件中,只需添加這一行。
android:windowSoftInputMode="stateHidden|adjustResize"
例如,
<activity
android:name="packagename.ClassName"
android:label="@string/app_name"
android:windowSoftInputMode="stateHidden|adjustResize" >
</activity>
你很高興去。
在您的AndroidManifest
文件和activity
更改以添加屬性,例如
android:windowSoftInputMode="adjustResize"
到這個直接打開鍵盤到上面的按鈕。
在活動標記下的清單文件中,添加以下行。
android:windowSoftInputMode="adjustPan|adjustResize"
在您的AndroidManifest.xml
嘗試以下代碼:
<activity
android:name="com.facebook.FacebookActivity"
android:windowSoftInputMode="adjustPan|adjustResize"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
就我而言,我在我的主題中使用了<item name="android:windowFullscreen">true</item>
。 它產生了問題,我使用了android:windowSoftInputMode="adjustResize"
。
你可以使用android:layout_alignParentBottom="true"
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.