【发布时间】:2020-11-03 17:14:10
【问题描述】:
我在我的设计中使用TextInputLayout 来显示价格布局。添加了suffixText 用于显示货币符号,该符号必须恰好显示在输入的文本旁边。
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textfield_downpayment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Price Details"
app:boxBackgroundColor="@android:color/transparent"
app:hintEnabled="true"
android:textColorHint="#ffffff"
app:suffixTextColor="#ffffff"
app:suffixText="LE">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:inputType="number"
android:text="1234" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
截至目前,suffixText 显示在末尾,这不是我的预期行为。需要删除text和suffixText之间的明显间隙
尝试将TextInputEditText 的layout_width 更改为wrap_content,这也将提示文本包装在TextInputLayout 中。
【问题讨论】:
-
你能把整个xml文件贴出来吗?
-
已更新完整版式
标签: android material-design material-components-android android-textinputlayout android-textinputedittext