Java Android编辑文本错误与操作栏重叠
有人知道如何在actionbar后面显示错误消息吗 请检查这是我的xml设计文件:Java Android编辑文本错误与操作栏重叠,java,android,xml,Java,Android,Xml,有人知道如何在actionbar后面显示错误消息吗 请检查这是我的xml设计文件: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_second" andr
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_second"
android:layout_width="match_parent"
android:layout_height="match_parent">
<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"
tools:context=".MainActivity" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/editTextlastname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="lastname"
android:layout_marginTop="15dp"
android:paddingBottom="1000dp"
android:inputType="text"/>
</RelativeLayout>
</ScrollView>
我认为您正在一次对所有编辑文本进行验证使用| | in if block逐个进行验证使用&&而不是| |,它将自动将您的姓氏代码聚焦在操作栏下方并显示错误消息。如果您使用RelativeLayout作为主要父布局,则将其更改为LinearLayout并将方向设置为垂直。I找到此问题的解决方案请尝试此
发布您的xml代码如果您使用的是相对布局,那么请使用下面的标记>>android:layout_=…尝试将android:paddingTop=?android:attr/actionBarSize添加到父级layout@Raghavendra我尝试使用android:paddingTop=?android:attr/actionBarSize,但不工作发布布局文件
scrollView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (yourEditText.getError() != null) {
yourEditText.setError(null);
return true;
}
return false;
}
});