【问题标题】:How to Adjust the Alignment in Hints如何调整提示中的对齐方式
【发布时间】:2020-08-30 16:17:10
【问题描述】:

不确定在哪里添加,应用程序上的提示被输入design.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..." />

The Issues of the Hints in the Layout

【问题讨论】:

  • 输入设计代码 schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width ="match_parent" android:layout_height="match_parent"> 跨度>
  • 抱歉刚刚发现需要添加android:padding="20dp"

标签: android android-textinputlayout hint


【解决方案1】:

你可以使用 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>

【讨论】:

  • 刚发现需要添加android:padding="20dp" 感谢分享
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-17
  • 2014-01-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多