0

I have a ListView with some rows and a custom checkbox on the right hand side. On my OS 4.4 Nexus 4 it seems like a gentle gradient is being applied to the list row backgrounds, creating an ugly artifact on the checkboxes (they disappear half way down, and then invert for the bottom half). On other devices I don't see this problem, and I also don't see it in an OS 4.4.2 emulator.

I haven't been able to find any information online about this, so I'm not sure if it's specific to the device, or the exact OS flavor.

Is this something I can disable? If not, what advice should I give my asset designer?

Here's a screenshot:

screen gradient

Dan J
  • 25,433
  • 17
  • 100
  • 173

3 Answers3

1

The Holo.Light theme uses a subtle grey gradient background. It might only be more apparent on one of your devices due to the screen's contrast/brightness.

You can just set the background to solid white by using the android:windowBackground tag in your Activity's theme:

<style name="SolidWhiteTheme" parent="android:Theme.Holo.Light">
  <item name="android:windowBackground">@android:color/white</item>
  <item name="android:colorBackground">@android:color/white</item>
</style>

And then applying the theme to your activity in your AndroidManifest.xml like so:

<activity 
    android:theme="@style/SolidWhiteTheme"
    ...
    >

    ...
</activity>
Denley Bihari
  • 591
  • 3
  • 8
  • Thanks for the explanation of the cause! Adding a Theme for my activity does solve the gradient problem, but unfortunately the Theme has some undesirable side effects for me, like making an action bar appear. I prefer @varsha-venkatesh's suggestion as it is a more tightly directed fix. – Dan J Oct 14 '14 at 00:27
  • In that case you should use `parent="Theme.Holo.Light.NoActionBar"` or `parent="Theme.Light"` (or whatever theme you were using originally). If you apply the background only to the ListView then you have an inconsistent background between pages in your app. It may be a quick fix but it lacks regard for the overall design of your app. – Denley Bihari Oct 14 '14 at 07:44
  • I have a list row style that includes a background color. My list rows don't match the window background color, so this feels like a better fit for us than using an activity Theme. – Dan J Oct 14 '14 at 21:21
0

Try specifying a background color for your activity (android:background). If the background is not explicitly set, the device may be using it's own device-specific default background, which is why the gradient is only shown on your Nexus 4 and not other devices.

Richard
  • 560
  • 1
  • 8
  • 17
0

As Denley mentioned, the reason for this is the default background specified by the Holo.Light theme. However, since this background is specifically affecting your ListView, I would suggest setting the background of your ListView in your xml file. Code below.

<ListView
    android:background="@android:color/white">
  • Thanks, I can confirm this fixes the issue. Another easy fix is to add the background directly into the layout being inflated for each list view row. – Dan J Oct 14 '14 at 00:28