[英]How do I top start the hint text within an TextInputEditText in Android?
I need [top|start] hint text an TextInputEditText.. I use android:gravity="top|start"
hint text still in center, but the text content is correct (top start)我需要 [top|start] 提示文本 TextInputEditText .. 我使用android:gravity="top|start"
提示文本仍然在中心,但文本内容是正确的(顶部开始)
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:counterEnabled="true"
app:counterMaxLength="200">
<com.google.android.material.textfield.TextInputEditText
android:text="@={textProg.textProg.text}"
android:hint="Hint Text"
android:layout_width="match_parent"
android:layout_height="100dp"
android:inputType="textMultiLine"
android:gravity="top|start"
android:maxLength="200"
android:textColor="@drawable/edit_text_color"/>
</com.google.android.material.textfield.TextInputLayout>
i don't know why your code doesn't work with you it work with me , but you can try this i hope it work .我不知道为什么你的代码对你不起作用,它对我起作用,但你可以试试这个,我希望它起作用。
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
app:counterEnabled="true"
app:counterMaxLength="200">
<com.google.android.material.textfield.TextInputEditText
android:text="@={textProg.textProg.text}"
android:hint="Hint Text"
android:layout_width="match_parent"
android:layout_height="100dp"
android:inputType="textMultiLine"
android:ellipsize="start"
android:gravity="top"
android:maxLength="200"
/>
</com.google.android.material.textfield.TextInputLayout>
为什么你不尝试添加这个android:ellipsize="top|start"
Probably it's an issue related to material design library.可能是与材料设计库相关的问题。 I have checked with different version and found different scenarios for same layout
.我检查了不同的版本,发现相同layout
不同场景。 Among them below version gives me the result that you want to achieve.其中下面的版本给了我你想要达到的结果。
implementation 'com.google.android.material:material:1.2.0-alpha01'
Output:输出:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.