Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android编辑文本错误与操作栏重叠_Java_Android_Xml - Fatal编程技术网

Java Android编辑文本错误与操作栏重叠

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

有人知道如何在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"
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;
        }
    });