【问题标题】:TextInputLayout boxBackgroundColor not working after 'com.google.android.material:material:1.1.0-alpha02'TextInputLayout boxBackgroundColor 在“com.google.android.material:material:1.1.0-alpha02”之后不起作用
【发布时间】:2019-12-05 03:58:08
【问题描述】:

我遇到的问题是,当我想在设计库的“com.google.android.material:material:1.1.0-alpha02”之后的版本上设置 TextInputLayout 上的 boxBackgroundColor 时,我没有看到任何更改,因为我想要要使用仅在更高版本中支持的 ExposedDropdownMenu,我似乎找不到任何解决方案。 我尝试在 java 和样式中设置它,但没有结果。

<com.google.android.material.textfield.TextInputLayout
    style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/Theme.MaterialComponents"
    app:boxBackgroundColor="@color/colorAccent"
    android:hint="@string/hint_text">

  <AutoCompleteTextView
      android:id="@+id/filled_exposed_dropdown"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"/>

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

【问题讨论】:

    标签: android material-design android-textinputlayout material-components material-components-android


    【解决方案1】:

    查看doc

    注意:当使用带有 EditText 子级的填充文本字段时,该子级不是 TextInputEditText,确保将EditTextandroid:background 设置为 @null。这允许TextInputLayoutEditText.

    只需使用:

     <com.google.android.material.textfield.TextInputLayout
          style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
            app:boxBackgroundColor="@color/primaryLightColor"
            ...>
    
    
          <AutoCompleteTextView
              android:background="@null"
              .../>
    
        </com.google.android.material.textfield.TextInputLayout>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多