【发布时间】:2017-08-07 12:56:39
【问题描述】:
在我的布局中,我有一些编辑文本和滚动视图。问题是当我触摸编辑文本时,软键盘是打开的,但如果我尝试向下滚动,它不会完全向下滚动。当我尝试完全向上滚动时也会发生同样的情况。
但如果我使用 android:windowSoftInputMode="adjustresize" 我可以完全向上滚动,但我的键盘隐藏了底部的编辑文本。我也尝试使用 android : windowSoftInputMode="adjustspan|adjustresize" 但没有找到解决方案。
另一个问题是,当用户尝试输入相同的文本(如果匹配)时,我会显示一些错误消息,但是当关闭软键盘时,消息未附加到正确的位置。
这是我的布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent" >
<include
android:id="@+id/toolbar"
layout="@layout/toolabar"
android:theme="@style/mycustomtoolbartheme"></include>
<ScrollView
android:id="@+id/scrollView_addproductactivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:isScrollContainer="true"
>
<LinearLayout
android:id="@+id/activity_add_product"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp">
<Button
android:id="@+id/btn_save_addProductActivity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="5dp"
android:background="@drawable/shape1"
android:text="Save"
android:textColor="#fff" />
<Button
android:id="@+id/btn_view_addProductActivity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="5dp"
android:background="@drawable/shape1"
android:text="view"
android:textColor="#fff" />
</RelativeLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<AutoCompleteTextView
android:id="@+id/autocomplitePn"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Product Name"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<AutoCompleteTextView
android:id="@+id/autocompliteBn"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Brand Name"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="@+id/edittext_MN"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Model Num"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="@+id/edittext_Quantity"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Quantity"
android:imeOptions="flagNoExtractUi"
android:inputType="number"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="@+id/edittext_PPP"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Price per Pice"
android:imeOptions="flagNoExtractUi"
android:inputType="numberDecimal"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<AutoCompleteTextView
android:id="@+id/autocomplitecn"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Country "
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<AutoCompleteTextView
android:id="@+id/autocomplitecolor_name"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Color "
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="@+id/edittext_ProductSize"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Size"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<AutoCompleteTextView
android:id="@+id/autocompliteDname"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Dealer Name"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="@+id/edittext_Delleremail"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Dealer Email"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="@+id/edittext_DellerPhn"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Dealer Phn Num"
android:imeOptions="flagNoExtractUi"
android:inputType="phone"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="@+id/edittext_Delleradd"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Dealer Add"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="@+id/edittext_Dellerfax"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Dealer Fax"
android:imeOptions="flagNoExtractUi"
android:inputType="phone"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
我将此代码添加到我的清单文件中,但没有找到解决方案
<activity
android:name="com.example.oggy.productcatalog.AddProductActivity"
android:windowSoftInputMode="adjustPan"
/>
【问题讨论】:
标签: android