【发布时间】:2016-05-22 03:29:04
【问题描述】:
【问题讨论】:
-
所以你可以设置自定义主题,就像这里medium.com/@werder630/…
标签: android colors android-edittext drawable text-cursor
【问题讨论】:
标签: android colors android-edittext drawable text-cursor
您可以更改所有EditText 气泡和条形colors,在AppTheme 中设置强调色。
<style name="AppTheme" parent="Base.Theme.AppCompat.Light">
<item name="colorPrimary">@color/indigo</item>
<item name="colorAccent">@color/pink</item>
</style>
或者您可以只使用组件的android:theme 属性更改一个EditText。
<style name="MyEditText" parent="Theme.AppCompat.Light">
<item name="colorControlNormal">@color/indigo</item>
<item name="colorControlActivated">@color/pink</item>
</style>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Hint text"
android:theme="@style/MyEditText"
/>
【讨论】:
更改res/values/styles.xml 的颜色。气泡使用colorAccent:
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Other theme overrides here -->
<item name="colorAccent">@color/Gray2</item>
</style>
在上面的<item name="colorAccent">@color/Gray2</item> 是您为气泡添加所需颜色的行。
【讨论】:
http://developer.android.com/training/material/theme.html#ColorPalette
<resources>
<!-- inherit from the material theme -->
<style name="AppTheme" parent="android:Theme.Material">
<!-- Main theme colors -->
<!-- your app branding color for the app bar -->
<item name="android:colorPrimary">@color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="android:colorAccent">@color/accent</item>
</style>
</resources>
检查一下:主题 UI 控件,例如 checkboxes 和 text fields
<!-- theme UI controls like checkboxes and text fields -->
<item name="android:colorAccent">@color/accent</item>
很难找到吗? :)
【讨论】:
您需要更改您的主题 colorControlActivated 颜色。
source:Android源码中text_select_handle的默认实现。
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/text_select_handle_middle_mtrl_alpha"
android:tint="?attr/colorControlActivated" />
【讨论】:
您应该更改“colorAccent”,并且为了不更改整个应用程序的此参数,您可以使用 ThemeOverlay。更详细的可以阅读this article,最后一个主题“游标与选择”
【讨论】: