Skip to content

Commit

Permalink
Merge pull request #3758 from pingwang2011/timob-11865
Browse files Browse the repository at this point in the history
timob-11865: Android: When using Holo theme, table highlight color does not match
  • Loading branch information
hieupham007 committed Jan 23, 2013
2 parents 70cfc45 + 9f6693b commit ac08bf9
Showing 1 changed file with 7 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,35 +151,17 @@ public void setBackgroundDrawable(KrollDict d, Drawable drawable)
{
StateListDrawable stateDrawable = new StateListDrawable();

if (d.containsKey(TiC.PROPERTY_BACKGROUND_SELECTED_IMAGE)
|| d.containsKey(TiC.PROPERTY_BACKGROUND_SELECTED_COLOR)) {
// use transparent highlight selector drawable is visible over background
ColorDrawable transparent = new ColorDrawable(Color.TRANSPARENT);
stateDrawable.addState(new int[] {
android.R.attr.state_window_focused,
android.R.attr.state_enabled,
android.R.attr.state_pressed }, transparent);
stateDrawable.addState(new int[] { android.R.attr.state_selected }, transparent);
}
else
{
// set default drawable to system default manually so it works with custom background
Drawable defaultDrawable = getResources().getDrawable(R.drawable.list_selector_background);
stateDrawable.addState(new int[] {
android.R.attr.state_window_focused,
android.R.attr.state_enabled,
android.R.attr.state_pressed }, defaultDrawable);
stateDrawable.addState(new int[] { android.R.attr.state_selected }, defaultDrawable);
}
// use transparent highlight so the selector drawable is visible over background
ColorDrawable transparent = new ColorDrawable(Color.TRANSPARENT);
stateDrawable.addState(new int[] { android.R.attr.state_window_focused, android.R.attr.state_enabled,
android.R.attr.state_pressed }, transparent);
stateDrawable.addState(new int[] { android.R.attr.state_selected }, transparent);

stateDrawable.addState(new int[] {
android.R.attr.state_focused,
android.R.attr.state_window_focused,
stateDrawable.addState(new int[] { android.R.attr.state_focused, android.R.attr.state_window_focused,
android.R.attr.state_enabled }, drawable);
stateDrawable.addState(new int[0], drawable);

if (d.containsKey(TiC.PROPERTY_OPACITY))
{
if (d.containsKey(TiC.PROPERTY_OPACITY)) {
stateDrawable.setAlpha(Math.round(TiConvert.toFloat(d, TiC.PROPERTY_OPACITY) * 255));
}
setBackgroundDrawable(stateDrawable);
Expand Down

0 comments on commit ac08bf9

Please sign in to comment.