gpt4 book ai didi

Android Edit Text错误重叠其他组件

转载 作者:太空狗 更新时间:2023-10-29 14:00:57 25 4
gpt4 key购买 nike

我有一个问题,即编辑文本显示的错误消息与布局上的其他组件重叠。

有没有人知道如何在顶部和底部布局后面显示错误消息?

关于结构的一点点:顶部红色和底部灰色部分线性布局。主要中间内容是Frame Layout,其内容由应用处理。在这种情况下, ScrollView 中包含多个编辑文本。

<android.support.v4.widget.CustomDrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
tools:context=".MainActivity">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:fitsSystemWindows="true">

<com.custom.TitlebarLayout
android:id="@+id/titlebarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"/>


<FrameLayout
android:id="@+id/contentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:layout_gravity="top"/>

<com.custom.ButtonsToolbarLayout
android:id="@+id/buttonsToolbarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:gravity="center_vertical|left"
android:orientation="horizontal"/>

</RelativeLayout>

内部 contentContainer 位于布局下方:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:msa="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragment.addressedit.AddressEditFragment"
android:id="@+id/frame_layout_address_edit">

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollview_address_dialog"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:isScrollContainer="true"
android:orientation="horizontal">

<com.custom.editview.EditViewLayout
android:id="@+id/edittext_address_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linearlayout_address_top"
android:hint="Name"
android:maxLength="30"
android:maxLines="1"
android:singleLine="true"
android:inputType="textCapCharacters"
android:tag="etx_name1"/>

<com.custom.editview.EditViewLayout
android:id="@+id/edittext_address_name2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/edittext_address_name"
android:hint="Name2"
android:maxLength="30"
android:maxLines="1"
android:singleLine="true"
android:inputType="textCapCharacters"
android:tag="etx_name2"/>

<com.custom.editview.EditViewLayout
android:id="@+id/edittext_address_street"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/edittext_address_name2"
android:hint="Street"
android:maxLength="30"
android:maxLines="1"
android:singleLine="true"
android:inputType="textCapCharacters"
android:tag="etx_street"/>

<com.custom.editview.EditViewLayout
android:id="@+id/edittext_address_houseno"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/edittext_address_street"
android:hint="House No."
android:maxLength="8"
android:maxLines="1"
android:singleLine="true"
android:inputType="number"
msa:alternativeInputType="textNoSuggestions"
android:tag="etx_house_no"/>

<com.custom.editview.EditViewLayout
android:id="@+id/edittext_address_postcode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/edittext_address_houseno"
android:hint="Postcode"
android:maxLength="10"
android:maxLines="1"
android:singleLine="true"
android:inputType="textPostalAddress"
android:tag="etx_postcode1"
msa:validation="postcode"/>

<com.custom.editview.EditViewLayout
android:id="@+id/edittext_address_city"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/edittext_address_postcode"
android:hint="City"
android:maxLength="30"
android:maxLines="1"
android:singleLine="true"
android:inputType="textCapCharacters"
android:tag="etx_city"/>

<com.custom.editview.EditViewLayout
android:id="@+id/edittext_address_country"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/edittext_address_city"
android:hint="Country"
android:maxLength="5"
android:maxLines="1"
android:singleLine="true"
android:inputType="textCapCharacters"
android:tag="etx_country"/>

<com.custom.editview.EditViewLayout
android:id="@+id/edittext_address_phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/edittext_address_country"
android:hint="Phone"
android:maxLength="20"
android:maxLines="1"
android:singleLine="true"
android:inputType="phone"
android:tag="etx_phone1"/>

</RelativeLayout>

</ScrollView>

最佳答案

只需做一个简单的调整,你就可以开始了..

scrollView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
addressName.clearFocus();
addressName2.clearFocus();
houseNo.clearFocus();
phone.clearFocus();
return false;
}
})

;

关于Android Edit Text错误重叠其他组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35548406/

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