Remove disabled text alpha on v21/22 for borderless colored buttons
On versions 21 and 22 of the platform AppCompat's treatment of
app:alpha gets multiplied by the platform alpha for disabled controls.
Remove our own alpha to work around that.
Bug: 67027231
Test: visual inspection of the sample app
Change-Id: I7e1705c24a936d2bbd83e5ba3762b6a003b6b117
diff --git a/samples/Support7Demos/src/main/res/layout/appcompat_widgets_buttons.xml b/samples/Support7Demos/src/main/res/layout/appcompat_widgets_buttons.xml
index 517f4fa..ba4c045 100644
--- a/samples/Support7Demos/src/main/res/layout/appcompat_widgets_buttons.xml
+++ b/samples/Support7Demos/src/main/res/layout/appcompat_widgets_buttons.xml
@@ -73,40 +73,82 @@
</RadioGroup>
<Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button"/>
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Button"/>
<Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button (small)"
- style="@style/Widget.AppCompat.Button.Small"/>
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:enabled="false"
+ android:text="Button disabled"/>
<Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button (borderless)"
- style="@style/Widget.AppCompat.Button.Borderless"/>
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Button (small)"
+ style="@style/Widget.AppCompat.Button.Small"/>
<Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button (borderless + colored)"
- style="@style/Widget.AppCompat.Button.Borderless.Colored"/>
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:enabled="false"
+ android:text="Button (small) disabled"
+ style="@style/Widget.AppCompat.Button.Small"/>
<Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button (colored)"
- style="@style/Widget.AppCompat.Button.Colored"/>
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Button (borderless)"
+ style="@style/Widget.AppCompat.Button.Borderless"/>
<Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button (colored + tinted)"
- app:backgroundTint="#00FF00"
- style="@style/Widget.AppCompat.Button.Colored"/>
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:enabled="false"
+ android:text="Button (borderless) disabled"
+ style="@style/Widget.AppCompat.Button.Borderless"/>
+
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Button (borderless + colored)"
+ style="@style/Widget.AppCompat.Button.Borderless.Colored"/>
+
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:enabled="false"
+ android:text="Button (borderless + colored) disabled"
+ style="@style/Widget.AppCompat.Button.Borderless.Colored"/>
+
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Button (colored)"
+ style="@style/Widget.AppCompat.Button.Colored"/>
+
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:enabled="false"
+ android:text="Button (colored) disabled"
+ style="@style/Widget.AppCompat.Button.Colored"/>
+
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Button (colored + tinted)"
+ app:backgroundTint="#00FF00"
+ style="@style/Widget.AppCompat.Button.Colored"/>
+
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:enabled="false"
+ android:text="Button (colored + tinted) disabled"
+ app:backgroundTint="#00FF00"
+ style="@style/Widget.AppCompat.Button.Colored"/>
<RatingBar
android:layout_width="wrap_content"
diff --git a/v7/appcompat/res/color-v21/abc_btn_colored_borderless_text_material.xml b/v7/appcompat/res/color-v21/abc_btn_colored_borderless_text_material.xml
new file mode 100644
index 0000000..f5585e3
--- /dev/null
+++ b/v7/appcompat/res/color-v21/abc_btn_colored_borderless_text_material.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2017 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.
+ -->
+
+<!-- Used for the text of a borderless colored button. -->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_enabled="false"
+ android:color="?android:attr/textColorSecondary"/>
+ <item android:color="?attr/colorAccent"/>
+</selector>
\ No newline at end of file