gpt4 book ai didi

java - 调整平移不适用于 ScrollView 之外的参数

转载 作者:行者123 更新时间:2023-12-02 02:12:13 25 4
gpt4 key购买 nike

我在我的 list Activity 中使用调整平移,并且它在 ScrollView 中正常工作,但我有一些 ScrollView 之外的东西正在调整大小。

我将此代码放在 list 上的 Activity 上:

android:windowSoftInputMode="adjustPan"

你可以在图片中看到这一点。

Left one is before showing keyboard and right one is after showing keyboard

我在 viewpager 旁边使用它:

这是我的 viewpager xml,其中包含大量 edittext 。

Xml fragment :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<AutoCompleteTextView android:id="@+id/autotext"
android:layout_width="0dp"
android:layout_height="0dp"
android:nextFocusUp="@id/autotext"
android:nextFocusLeft="@id/autotext"/>

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal"
android:weightSum="2">

<Spinner
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/spinnerKind"
android:layout_weight="1"/>


<Spinner
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/spinnerSazande"
android:layout_weight="1"/>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:weightSum="2"
>

<EditText
android:id="@+id/model"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="مدل"
android:focusableInTouchMode="true"/>

<EditText
android:id="@+id/serial"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="سریال"
android:focusableInTouchMode="true"
/>


</LinearLayout>

<LinearLayout
android:id="@+id/LIMEI"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:weightSum="2"
>

<EditText
android:id="@+id/IMEI1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="IMEI"
android:gravity="right"
android:focusableInTouchMode="true"/>

<EditText
android:id="@+id/IMEI2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="IMEI2"
android:gravity="right"
android:focusableInTouchMode="true"/>





</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:weightSum="2"
>

<EditText
android:id="@+id/Size"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="سایز"
android:focusableInTouchMode="true"/>

<EditText
android:id="@+id/Color"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="رنگ"
android:focusableInTouchMode="true"/>





</LinearLayout>

<LinearLayout
android:id="@+id/LMojdegani"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:weightSum="2"
>

<EditText
android:id="@+id/MacAddress"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="MacAddress"
android:gravity="right"
android:focusableInTouchMode="true"/>


<EditText
android:id="@+id/mojdegani"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="مژدگانی"
android:focusableInTouchMode="true"/>


</LinearLayout>


<LinearLayout
android:id="@+id/LFactor"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:weightSum="2"
>

<EditText
android:id="@+id/FactorNumber"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="شماره فاکتور"
android:focusableInTouchMode="true"/>


<EditText
android:id="@+id/NameForoshande"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="نام فروشنده"
android:focusableInTouchMode="true"/>


</LinearLayout>

<LinearLayout
android:id="@+id/LTarikh"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:weightSum="1"
>

<EditText
android:id="@+id/Tarikh_Kharid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="تاریخ خرید"
android:focusableInTouchMode="true"/>



</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:weightSum="2"
>

<EditText
android:id="@+id/Name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="نام"
android:focusableInTouchMode="true"/>


<EditText
android:id="@+id/LastName"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="نام خانوادگی"
android:focusableInTouchMode="true"/>


</LinearLayout>


<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:weightSum="2"
>

<EditText
android:id="@+id/CodeMelli"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="کد ملی 10 رقمی"
android:focusableInTouchMode="true"/>


<EditText
android:id="@+id/Mobile"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="شماره موبایل"
android:focusableInTouchMode="true"/>


</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:orientation="horizontal"
android:weightSum="2"
>

<EditText
android:id="@+id/Explain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="توضیحات مربوط به کالا (اختیاری)"
android:focusableInTouchMode="true"/>


</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:orientation="vertical"
android:weightSum="2"
>

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="جنسیت"
android:gravity="center_vertical"
android:layout_marginRight="5dp"
android:layout_weight="1"/>

<RadioGroup
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="1"
android:weightSum="2">

<RadioButton
android:id="@+id/mard"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="مرد"/>

<RadioButton
android:id="@+id/zan"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="زن"/>


</RadioGroup>


</LinearLayout>


<Space
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_weight="1" />


<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:weightSum="1"
>

<TextView
android:id="@+id/confirm"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="تایید"
android:gravity="center"
android:background="@drawable/confirm"
android:layout_weight="1"
android:clickable="true"
android:layout_margin="5dp"/>


</LinearLayout>


</LinearLayout>
</ScrollView>
</LinearLayout>

这是我的主要 xml,它有一个线性布局,其中有 4 个可单击的文本,通过选择这些文本可以在页面之间查看寻呼机更改。

主要 XML :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">


<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
android:orientation="vertical">


<android.support.v7.widget.CardView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.85">

<LinearLayout
android:layout_margin="5dp"
android:background="@drawable/card2"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="4"
android:layout_weight="1.8">


<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
>

<TextView
android:gravity="center"
android:text="کالای مسروقه"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/stolled"
android:layout_weight="1"
android:clickable="true"/>
</LinearLayout>

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
>

<TextView
android:gravity="center"
android:text="کالای گم شده"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/losted"
android:layout_weight="1"
android:clickable="true"
/>
</LinearLayout>

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
>

<TextView
android:gravity="center"
android:text="پیدا شده"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/founded"
android:layout_weight="1"
android:clickable="true"/>
</LinearLayout>

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
>

<TextView
android:gravity="center"
android:text="کالای نو"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/fresh"
android:layout_weight="1"
android:clickable="true"/>
</LinearLayout>

</LinearLayout>
</android.support.v7.widget.CardView>




<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.15"
android:id="@+id/ViewPager"
>


</android.support.v4.view.ViewPager>

</LinearLayout>

</LinearLayout>

最佳答案

我认为,正如您所说,您已在 list 中声明了调整调整大小,如下右图所示?

 <activity
android:name=".MainActivity"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="landscape"/>

那么,请尝试添加

android:fitsSystemWindows="true"

在 xml 的父布局中。

关于java - 调整平移不适用于 ScrollView 之外的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49850722/

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