如何调整Hints中的对齐方式

问题描述 投票:0回答:1

不知道在哪里添加,应用上的提示是由输入设计.xml覆盖的。

<EditText
    android:id="@+id/product_name"
    android:layout_width="350dp" //match_parent or wrap_content produce same issue
    android:layout_height="40dp"
    android:layout_below="@+id/select_product_image"
    android:layout_centerHorizontal="true"
    android:layout_marginStart="95dp"
    android:layout_marginLeft="45dp"
    android:layout_marginTop="5dp"
    android:layout_marginRight="45dp"
    android:background="@drawable/input_design"
    android:hint="Product Name..." />

布局中的提示问题。

android android-textinputlayout hint
1个回答
0
投票

你可以使用TextInputLayout。

 <com.google.android.material.textfield.TextInputLayout
    android:id="@+id/textInputLayout"
    style="@style/TextInputLayoutStyle"
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/enough_margin"
    app:layout_constraintEnd_toEndOf="@+id/textInputLayout2"
    app:layout_constraintStart_toStartOf="@+id/textInputLayout2"
    app:layout_constraintTop_toBottomOf="@+id/textInputLayout2">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/edt_Login_password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="product name . . ."
        android:imeOptions="flagNoExtractUi"
        android:inputType="textPassword"
        android:lines="1"
        android:maxLines="1"
        android:singleLine="true"
        android:textColorHighlight="@color/material_blue_500"
        android:textCursorDrawable="@color/black"
        android:textSize="18sp" />

</com.google.android.material.textfield.TextInputLayout>

添加到style.xml中。

 <style name="TextInputLayoutStyle" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
    <item name="boxStrokeColor">@color/colorAccent</item>
    <item name="boxStrokeWidth">2dp</item>
</style>
© www.soinside.com 2019 - 2024. All rights reserved.