Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.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
Android TextInputLayout中分隔线和错误文本之间的填充_Android_Android Layout_Android Textinputlayout - Fatal编程技术网

Android TextInputLayout中分隔线和错误文本之间的填充

Android TextInputLayout中分隔线和错误文本之间的填充,android,android-layout,android-textinputlayout,Android,Android Layout,Android Textinputlayout,如何设置文本输入布局中分隔线和错误文本(在图像中用问号标记)之间的填充?我尝试以指定为errorTextAppearance的样式添加填充,但没有效果 编辑:以下是布局: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xml

如何设置
文本输入布局
分隔线
错误文本
(在图像中用问号标记)之间的填充?我尝试以指定为
errorTextAppearance
的样式添加填充,但没有效果

编辑:以下是布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="test.textinputlayouttest.MainActivity">

    <android.support.design.widget.TextInputLayout
        android:id="@+id/address"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:errorEnabled="true"
        app:errorTextAppearance="@style/Error">

        <EditText
            android:id="@+id/username"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Enter address"
            android:inputType="textEmailAddress"
            android:padding="26dp"/>
    </android.support.design.widget.TextInputLayout>

</android.support.constraint.ConstraintLayout>

风格:

<style name="Error" parent="TextAppearance.AppCompat">
    <item name="android:textColor">@color/red</item>
    <item name="android:paddingBottom">300dp</item>
</style>

@颜色/红色
300dp

试试这个方法。。我想这会管用的

<android.support.design.widget.TextInputLayout
            android:id="@+id/usernameWrapper"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <EditText
                android:padding="26dp"
                android:id="@+id/username"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textEmailAddress"
                android:hint="Username"/>

        </android.support.design.widget.TextInputLayout>

您可以使用

TextView textView = (TextView) inputLayout.findViewById(android.support.design.R.id.textinput_error);

并修改布局参数。

如果只需要在
分隔线
错误文本

使用前面的示例进行更改
android:padding=“26dp”
to->
android:layout\u marginBottom=“20dp”



no,这并没有改变填充,但无论错误文本是否可见,这都会增加底部边距
<android.support.design.widget.TextInputLayout
                android:id="@+id/usernameWrapper"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <EditText
                    android:layout_marginBottom="20dp"
                    android:id="@+id/username"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textEmailAddress"
                    android:hint="Username"/>

            </android.support.design.widget.TextInputLayout>