Tint a view ?

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Tint a view ?

Postby velocity » Sat Jun 06, 2009 1:55 pm

How do I tint a view for example a TextView when I set the BackgroundColor for the TextView its not translucent . I found an example here take a look at this screenshot .
How did they manage to do that ?
Junior Developer
Junior Developer
Posts: 14
Joined: Tue Aug 19, 2008 12:05 pm


Postby keylimepai » Sun Jun 07, 2009 10:05 pm

First, in your AndroidManifest.xml file, add:

Code: Select all

Next, add these lines (or similar) to wherever you're displaying this:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.    getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND,
  2.         WindowManager.LayoutParams.FLAG_DIM_BEHIND);
  3.    WindowManager.LayoutParams lp = getWindow().getAttributes();
  4.    lp.alpha = 0.8f; // 80% alpha
  5.    lp.dimAmount = 0.5f; // Dim by 50%
  6.    getWindow().setAttributes(lp);
Parsed in 0.033 seconds, using GeSHi

There is also "FLAG_BLUR_BEHIND", which blurs everything behind it, rather than dimming it.

EDIT: It's probably possible to do these things with a full screen application, like is shown there, but it's not done exactly like that, but hopefully this can point you in the right direction!

EDIT2: Just change "@android:style/Theme.Dialog" to "@android:style/Theme. Translucent" and it will work for full screen.

You might want to add a "requestWindowFeature(Window.FEATURE_NO_TITLE);" in there as well. (Just remember to do so before setting it as the content view)
Junior Developer
Junior Developer
Posts: 14
Joined: Wed May 27, 2009 7:14 pm


Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Exabot [Bot] and 4 guests