Tal*_*lib 4 android label textview android-edittext material-design
我试图在编辑文本上添加边框并在其上添加标签.我做了这样的边框:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="1dp"
android:color="#A0A0A0" />
</shape>
Run Code Online (Sandbox Code Playgroud)
但我无法达到我想要的结果.
我想要下面的东西:
请帮忙.
小智 10
请查看此链接,了解有关创建所需新材料设计文本字段的指南.
https://material.io/design/components/text-fields.html#usage
- 如何使用它:
要创建材质文本字段,请将TextInputLayout添加到XML布局,将TextInputEditText添加为直接子项.
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_text"/>
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
注意:您还可以使用EditText作为输入文本组件.但是,使用TextInputEditText允许TextInputLayout更好地控制输入文本的可视方面 - 它允许TextInputLayout在"提取模式"(例如横向模式)下在文本字段中显示提示.
- 用于造型:
填充框(默认)
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
Run Code Online (Sandbox Code Playgroud)
大纲框
style="@style/Widget.MaterialComponents.TextInputLayout.OutlineBox"
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请查看此链接:
https://material.io/develop/android/components/text-input-layout/
我希望这将有所帮助.
小智 8
尝试这个:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:background="@drawable/boarder"
android:paddingLeft="5dp"
android:text="input" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="7dp"
android:background="#ffffff"
android:text="Label" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
寄宿生.xml :
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="2dp"
android:color="#03A6F0" />
<corners android:radius="12dp" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5699 次 |
| 最近记录: |