gpt4 book ai didi

android - 带有 scorll View 的 EditText

转载 作者:行者123 更新时间:2023-11-29 01:04:10 25 4
gpt4 key购买 nike

我使用了带有线性布局的 ScrollView ,在线性布局中有一个编辑文本,当我按下它时,键盘将其隐藏我通过将 ScrollView 更改为线性布局来解决它,但必须使整个 View 可滚动.代码在这里

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/loginbackground"
android:orientation="vertical"
android:id="@+id/mScrollView"
tools:context="com.mostafa.android.riahana.calculateActivity">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp">
<ImageView
android:layout_width="30dp"
android:layout_height="wrap_content"
android:onClick="backIcon"
android:src="@drawable/black_24dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/item_calculate"
android:textAllCaps="true"
android:textAppearance="?android:textAppearanceLarge"
android:textColor="@color/white"
android:textStyle="bold" />


<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingTop="10dp">

<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/ima1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:layout_marginLeft="50dp"
android:background="@drawable/whitecircle"
android:src="@drawable/pppp" />

<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/ima2"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_marginBottom="10dp"

android:layout_marginRight="50dp"
android:background="@drawable/whitecircle"
android:src="@drawable/pppp" />

<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/ima3"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:src="@drawable/pic" />

</FrameLayout>

<TextView
android:id="@+id/editPicture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:onClick="getImageFromGalary"
android:text="@string/selectYourPic"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="@color/white"
android:textStyle="bold" />

<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@color/white" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/selectServices"
android:textAppearance="?android:textAppearanceLarge"
android:textColor="@color/white" />

<TextView
android:id="@+id/selectservices"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/eyeleftprocess"
android:textAppearance="?android:textAppearanceLarge"
android:textColor="@color/white"
android:textStyle="bold" />

<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_marginTop="20dp"
android:background="@color/white" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/Description"
android:textAppearance="?android:textAppearanceLarge"
android:textColor="@color/white" />

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/DescriptionYourAge"
android:inputType="textMultiLine"
android:textColor="@color/white"
android:id="@+id/myedittext"
android:textStyle="bold"
android:scrollbars="vertical"/>

<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_marginTop="10dp"
android:background="@color/white" />


<TextView
android:id="@+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:drawableRight="@drawable/arrow"
android:text="@string/send"
android:textAppearance="?android:textAppearanceLarge"
android:textColor="@color/white" />
</LinearLayout>

</ScrollView>

enter image description here

enter image description here

最佳答案

试试这个让你的 ScrollView android:fillViewport="true"

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/loginbackground"
android:orientation="vertical"
android:id="@+id/mScrollView"
android:fillViewport="true"
tools:context="com.mostafa.android.riahana.calculateActivity">

并在 list 文件中使用 android:windowSoftInputMode=""adjustPan" 这样的 Activity

    <activity
android:name=".YourActivity"
android:windowSoftInputMode="adjustPan"/>

关于android - 带有 scorll View 的 EditText,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48805489/

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