android - android中的Textview设计
解决方案
用一个TextInputLayout
<com.google.android.material.textfield.TextInputLayout
app:boxBackgroundColor="@color/white"
app:placeholderText="Name"
app:hintEnabled="false">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</com.google.android.material.textfield.TextInputLayout>
否则,您可以将 aMaterialShapeDrawable
应用于您的EditText
(或TextView
)。
在您的布局中定义:
<EditText
android:layout_width="match_parent"
android:layout_height="56dp"
android:id="@+id/edittext"
android:paddingStart="4dp"
android:hint="Name"/>
然后:
val radius = resources.getDimension(R.dimen.cornerSize8)
val textView: EditText = findViewById(R.id.edittext)
val shapeAppearanceModel = ShapeAppearanceModel()
.toBuilder()
.setAllCorners(CornerFamily.ROUNDED, radius)
.build()
val shapeDrawable = MaterialShapeDrawable(shapeAppearanceModel)
shapeDrawable.fillColor = AppCompatResources.getColorStateList(this,R.color.white)
ViewCompat.setBackground(textView, shapeDrawable)
推荐阅读
- java - Spring Data JPA 方法 - 查找父级和有条件的子级
- sql - 错误:“(”或附近的语法错误。问题:无法创建表
- python-3.x - 是否可以在 Matillion 中编写“正确的”Python 代码?
- websphere - Websphere 8.5.5 安装:我们需要什么包?
- python-3.x - 'NoneType' 对象在 while 循环内不可迭代
- firebase - 如何保存 reyclerview 的滚动位置?
- automation - 如何使用 Cucumber 和 RestAssured 将场景一中的数据用于另一个场景
- html - 简化这个 css svg 动画
- javascript - 在这里阻止每个 setState 的 componentWillReceivePropsrender 吗?
- r - 评估具有不同长度的多个二进制测试答案的正确统计测试/ R 函数是什么?