【问题标题】:Style Text Color and Hint Color For AutocompleteSupportFragment In AndroidAndroid中AutocompleteSupportFragment的样式文本颜色和提示颜色
【发布时间】:2021-12-18 15:33:14
【问题描述】:

当我从 Google Places 中选择一个地点时,我无法更改提示文本和文本的颜色。

请看附图。

我尝试了 android:textColorHint 和 android:editTextColor 无济于事。想法?

【问题讨论】:

    标签: android android-edittext styles hint autocompletesupportfragment


    【解决方案1】:

    Google 不提供通过属性或样式指定颜色的选项。但是,您可以使用这些调整:

    对于 Activity(在 setContentView 之后):

    val searchView = findViewById<EditText>(R.id.places_autocomplete_search_input)
    
    searchView.setHintTextColor(Color.WHITE)
    searchView.setTextColor(Color.WHITE)
    

    对于 Fragment(在 onViewCreated 内):

    val searchView = view.findViewById<EditText>(R.id.places_autocomplete_search_input)
    
    searchView.setHintTextColor(Color.WHITE)
    searchView.setTextColor(Color.WHITE)
    

    警告:这些是内部布局 ID,可能会在 未来。该信息适用于版本 2.5.0

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-18
      • 1970-01-01
      相关资源
      最近更新 更多