gpt4 book ai didi

java - 显示键盘时如何调整布局大小

转载 作者:行者123 更新时间:2023-12-01 12:24:35 24 4
gpt4 key购买 nike

弹出键盘时布局不完全可见。我尝试了很多示例。但它不起作用。任何帮助将不胜感激。提前致谢。我的manifest.xml文件是

       <activity
android:name=".activity.SignUp"
android:windowSoftInputMode="stateVisible|adjustResize"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

我的布局文件是

    <?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:fitsSystemWindows="true"
android:focusableInTouchMode="false"
android:orientation="vertical">


<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:src="@drawable/userprofile" />

<EditText
android:id="@+id/editText"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginBottom="-10dp"
android:layout_marginLeft="80dp"
android:hint="USERNAME"
android:inputType="textPersonName"
/>

<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText"
android:layout_marginLeft="39dp"
android:layout_marginTop="30dp"
android:src="@drawable/email" />

<EditText
android:id="@+id/editText2"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/imageView3"
android:layout_alignLeft="@+id/editText"
android:layout_alignStart="@+id/editText"
android:hint="ENTER EMAIL"
android:inputType="textEmailAddress"
/>

<ImageView
android:id="@+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageView3"
android:layout_marginLeft="39dp"
android:layout_marginTop="20dp"
android:src="@drawable/passunlock" />

<EditText
android:id="@+id/editText3"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/imageView4"
android:layout_marginLeft="80dp"
android:layout_marginTop="-15dp"
android:hint="ENTER PASSWORD"
android:inputType="textPassword"
android:text="password" />

<ImageView
android:id="@+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/imageView6"
android:layout_alignLeft="@+id/imageView4"
android:layout_alignStart="@+id/imageView4"
android:src="@drawable/password" />

<EditText
android:id="@+id/editText4"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_below="@+id/editText3"
android:layout_marginLeft="80dp"
android:layout_marginTop="10dp"
android:hint="RETYPE PASSWORD"
android:inputType="textPassword"
android:text="password" />

<ImageView
android:id="@+id/imageView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText4"
android:layout_centerHorizontal="true"
android:layout_marginTop="39dp"
android:src="@drawable/signup" />

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/imageView6"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:text="SIGN UP"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@android:color/white" />

<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginRight="-14dp"
android:layout_toLeftOf="@+id/imageView6"
android:layout_toStartOf="@+id/imageView6"
android:src="@drawable/username" />

最佳答案

将 Window SoftInput Mode 属性设置为 adjustmentPan 和 adjustmentResize

<activity android:windowSoftInputMode="adjustPan|adjustResize"> </activity>  OR
<activity android:windowSoftInputMode="adjustResize"> </activity> OR
<activity android:windowSoftInputMode="adjustPan"> </activity>

如果以上任何一个不起作用,请在 onCreate() 方法中使用以下代码:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

关于java - 显示键盘时如何调整布局大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26459820/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com