gpt4 book ai didi

java - 当 editText 聚焦且键盘打开时如何移动 View ?

转载 作者:太空宇宙 更新时间:2023-11-04 10:21:23 24 4
gpt4 key购买 nike

我有一个 ScrollView

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
tools:context=".LoginActivity">

<RelativeLayout
android:id="@+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:focusableInTouchMode="true"
android:orientation="vertical">

<ImageView
android:layout_width="wrap_content"
android:layout_height="150dp"
android:layout_margin="55dp"
android:src="@drawable/sss" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/helvetica_neue_cyr_roman"
android:padding="4dp"
android:text="@string/title_email"
android:textColor="@color/colorWhite"
android:textSize="14sp" />

<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:errorEnabled="true"
app:errorTextAppearance="@style/ErrorText"
app:hintEnabled="false"
app:passwordToggleEnabled="true"
app:passwordToggleTint="@color/colorAccent">

<AutoCompleteTextView
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="46dp"
android:backgroundTint="@color/colorWhite"
android:fontFamily="@font/helvetica_neue_cyr_medium"
android:hint="@string/hint_email"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true"
android:textColor="@color/colorWhite"
android:textColorHint="@color/colorHint"
android:textSize="14sp" />

</android.support.design.widget.TextInputLayout>


<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/helvetica_neue_cyr_roman"
android:padding="4dp"
android:text="@string/title_password"
android:textColor="@color/colorWhite"
android:textSize="14sp" />

<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:errorEnabled="true"
app:errorTextAppearance="@style/ErrorText"
app:hintEnabled="false"
app:passwordToggleEnabled="true"
app:passwordToggleTint="@color/colorAccent">

<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/colorWhite"
android:fontFamily="@font/helvetica_neue_cyr_medium"
android:hint="@string/hint_password"
android:imeActionId="6"
android:imeActionLabel="@string/action_sign_in"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true"
android:textColor="@color/colorWhite"
android:textColorHint="@color/colorHint"
android:textSize="14sp" />

</android.support.design.widget.TextInputLayout>

<Button
android:id="@+id/sign_in_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/button_shape"
android:fontFamily="@font/helvetica_neue_cyr_medium"
android:text="@string/action_sign_in"
android:textAllCaps="false"
android:textColor="@color/colorWhite"
android:textSize="16sp" />
</LinearLayout>
</RelativeLayout>

我在展示我真正需要的东西时遇到了一些问题。

This is how view looks by default不可滚动

Clicking on email editText可滚动

Password editText click可滚动

And this is the screenshot i want the app to look like

我的意思是 - 如果我单击 editTexts,我需要将 View 移至相同位置。键盘消失后,我需要 View 到达默认位置。

键盘打开后我不需要 ScrollView 。

我一直在尝试通过添加来实现这一点

android:windowSoftInputMode="adjustResize"

android:windowSoftInputMode="adjustPan"

体现

有可能制作吗?

谢谢。

最佳答案

我相信,通过正确的布局配置(也许只是约束布局而不是滚动?),您可以在单击其中一个字段时以编程方式使用 Visibility.GONE 隐藏 Logo ,并在字段失去焦点时恢复 Logo 。

关于java - 当 editText 聚焦且键盘打开时如何移动 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51118476/

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