I've seen some SO questions and they gave some possible methods to achieve what I want. For example:
Use
colorControlHighlight
attribute in styles.xml.Here is my styles-v21.xml:
<style name="SelectableItemBackground"> <item name="android:colorControlHighlight">#5677FC</item> <item name="android:background">?attr/selectableItemBackground</item> </style>
And my widget:
<TextView android:id="@+id/tv_take_photo_as_bt" android:layout_width="280dp" android:layout_height="48dp" android:text="@string/act_take_photo" style="@style/SelectableItemBackground"/>
And it doesn't work. I also tried to add
parent="Theme.AppCompat
to "SelectableItemBackground" style, or change tocolorControlHighlight(no android: prefix)"
, or change to?android:attr/selectableItemBackground
, neither is useful.Use
backgroundTint
attribute in layout.So I add
android:backgroundTint="#5677FC"
to myTextView
. Still useless. Then I tried to changeandroid:backgroundTintMode
tosrc_in
andsrc_atop
, and they never make a difference.
So, how can I change ripple color when I use ?attr/selectableItemBackground
as background. I only focus on Lollipop and above. Thank you in advance!