Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/221.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 如何使用红色Astrick标记制作TextInputLayout_Android_Android Layout - Fatal编程技术网

Android 如何使用红色Astrick标记制作TextInputLayout

Android 如何使用红色Astrick标记制作TextInputLayout,android,android-layout,Android,Android Layout,我试图使用TextInputLayout来设置必填字段。我使用了Spanable类,但以单色显示TextInputLayout的提示。我希望我的视图看起来像下面的链接 我创建了以下文本InputItemText,使其看起来尽可能类似于“材质设计”文本字段 XML布局 <android.support.design.widget.TextInputLayout android:id="@+id/etlayout" and

我试图使用TextInputLayout来设置必填字段。我使用了Spanable类,但以单色显示TextInputLayout的提示。我希望我的视图看起来像下面的链接


我创建了以下文本InputItemText,使其看起来尽可能类似于“材质设计”文本字段

XML布局

            <android.support.design.widget.TextInputLayout
            android:id="@+id/etlayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:counterEnabled="true"
            app:counterMaxLength="25">

            <android.support.design.widget.TextInputEditText
                android:id="@+id/et"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingTop="16dp"
                android:layout_marginLeft="-4dp"
                android:layout_marginStart="-4dp"
                android:layout_marginTop="8dp"
                android:textSize="16sp"
                android:inputType="text|textCapSentences"
                android:singleLine="true"
                android:hint="@string/title"
                android:textColorHint="@color/transparent38"/>

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

对不起,这不是StackOverflow的工作方式。形式为“我想做X,请给我提示和/或示例代码”的问题被认为是离题的。请访问并阅读,特别是阅读Why is
<color name="transparent38">#66000000</color>
etlayout = (TextInputLayout)findviewbyid(R.id.etlayout);

        TextWatcher twTitle = new TextWatcher() { //Analyzes when the view changes
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                if (true) { //Replace condition with validity test
                etlayout.setErrorEnabled(false); //Removes the extra space
                etlayout.setError(null); //Removes the error message
            } else { //If the text is not valid
                etlayout.setErrorEnabled(true); //Makes the space for the error appear
                etlayout.setError("Invalid input"); //Shows a message
            }
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        };
        etTitle.addTextChangedListener(twTitle);