[英]How to move whole layout move up when soft keyboard open in android
我要移動其中具有多個視圖的布局,因此,當用戶觸摸編輯文本然后打開鍵盤時,布局小部件就會上升。 我什至在清單清單android:windowSoftInputMode =“ adjustPan”中使用代碼,然后在android:windowSoftInputMode =“ adjustPan | adjustResize”中使用任何代碼都無法正常工作,請幫幫我
這是我的xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/theme_color"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/relativeLAyoutId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:focusable="true"
android:focusableInTouchMode="true" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@drawable/osmosis_label" />
<EditText
android:id="@+id/login_screen_username_editText1"
android:layout_width="220dp"
android:layout_height="40dp"
android:layout_below="@+id/imageView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:ellipsize="start"
android:ems="10"
android:gravity="left"
android:hint="@string/username_editbox_text"
android:imeOptions="actionNext"
android:singleLine="true" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/login_screen_password_editText2"
android:layout_width="220dp"
android:layout_height="40dp"
android:layout_alignLeft="@+id/login_screen_username_editText1"
android:layout_below="@+id/login_screen_username_editText1"
android:layout_marginTop="15dp"
android:ellipsize="start"
android:ems="10"
android:gravity="left"
android:hint="@string/password_editbox_text"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:textColor="@color/login_layout" >
</EditText>
<ImageView
android:id="@+id/login_screen_submit_button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/login_screen_password_editText2"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:src="@drawable/log_in"
android:text="Login" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/login_screen_submit_button1"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:text="@string/registered_textview_id"
android:textColor="@color/grey_color"
android:textSize="18sp"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
將其放在您的oncreate中。
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.