【问题标题】:what's wrong in my xml code? I want to make a TextInputLayout but can't我的 xml 代码有什么问题?我想做一个 TextInputLayout 但不能
【发布时间】:2019-11-09 15:04:03
【问题描述】:

我的 xml 代码有什么问题?我想做一个 TextInputLayout 但做不到。你能帮我做什么来制作 TExtInputLayout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"    
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:Layout_marginTop="20dp"
        android:Layout_marginBot="20dp"
        android:layout_marginLeft="20dp"
        android:Layout_marginRight="20dp"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.widget.support.design.TextInputLayout
            android:layout_width="match parent"
            android:layout_heigth="wrap_content"
            android:drawableStart="@drawable/ouuu"
            android:id="@+id/etnama"
            android:hint"nama anda">

       </android.widget.support.designt.TextInputLayout>

    </LinearLayout>

</LinearLayout>

【问题讨论】:

    标签: android android-support-library android-textinputlayout material-components material-components-android


    【解决方案1】:

    通过设计支持库来使用TextInputLayout你 必须添加TextInputEditText
    比如:

    <android.support.design.widget.TextInputLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:id="@+id/etnama"
             ...>
    
         <android.support.design.widget.TextInputEditText
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 />
    
     </android.support.design.widget.TextInputLayout>
    

    使用 androidx 库,您必须添加 Material Components library 并使用:

    <com.google.android.material.textfield.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ...>
    
      <com.google.android.material.textfield.TextInputEditText
          android:layout_width="match_parent"
          android:layout_height="wrap_content"/>
    
    </com.google.android.material.textfield.TextInputLayout>
    

    【讨论】:

      猜你喜欢
      • 2020-09-12
      • 2021-07-03
      • 2016-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-18
      • 2020-08-26
      相关资源
      最近更新 更多