3

I have downloaded the latest android support library com.android.support:appcompat-v7:23.0.1 which I suppose support android:backgroundTint for android.support.v7.widget.AppCompatTextView. But I can't still get the tint working when I run it on devices lesser than Lollipop.

Here is what I did:

<android.support.v7.widget.AppCompatTextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content
    android:layout_alignParentRight="true"
    android:background="@drawable/balloon_outgoing_normal"
    android:backgroundTint="#222"
/>
special
  • 63
  • 1
  • 7

2 Answers2

1

After researching on my own, I found a third party library on github that uses a chat bubble and allows background color changing which is similar to the background tint effect. You can check it out on https://github.com/himanshu-soni/ChatMessageView

special
  • 63
  • 1
  • 7
0

Make sure your activity extends AppCompatActivity and your base theme uses any of the Theme.AppCompat theme as parent. Then add the following attributes to your base theme with your preferred color choices.

<item name="colorControlNormal">@color/primary_deepPurple_500</item>
<item name="colorControlHighlight">@color/primary_deepPurple_600</item>
<item name="colorControlActivated">@color/primary_dark_deepPurple_700</item>
<item name="colorButtonNormal">@color/primary_deepPurple_500</item>

The 500, 600 and 700 shades are according to the Material Design color palette.

That should tint your buttons.

Btw, you don't need to directly use android.support.v7.widget.AppCompatTextView in your layouts, unless when you're creating a custom TextView out of it. Their methods and variables (like the tint feature) are available to you when you extend AppCompatActivity. It is called polymorphism.

Community
  • 1
  • 1
Aditya Naique
  • 1,120
  • 13
  • 25
  • 1
    I am trying to tint a Text view and not a button. The text view has background drawable, a message bubble precisely. What I want to achieve is to be able to tint the background in pre lollipop devices. – special Sep 22 '15 at 05:25
  • Not sure, but may be this answer is what your need http://stackoverflow.com/a/29790025/1944049 Also skim the other answers in that thread. – Aditya Naique Sep 22 '15 at 05:30
  • 1
    I was able to get what I want using a third party library in github that uses a chat bubble and allows background color changing which is similar to the background tint effect. https://github.com/himanshu-soni/ChatMessageView – special Sep 22 '15 at 06:26
  • Cool! Consider posting this comment as an answer, and select it as the best answer so others can find it easily. – Aditya Naique Sep 22 '15 at 06:52