One for the dark color scheme and one for the light. In our layout file, we've created two TextView objects. Start this file by coping the simple_list_item_1 layout from the Android SDK. Next we're going to create a layout for the ListView rows. To disable the optimization, simply use the transparent color #00000000 and you won't have any problems. Scrolling the ListView changes all the TextView abjects back to their original color. When we customize the background color, the blending optimzation leaves part of the dark gradient at the bottom of the screen. The fade effect is implemented using a combination of Canvas.saveLayerAlpha() and the Porter-Duff Destination Out blending mode. Fading edges is a gradient display rendered as a very dark gray to black fade. The fading edges technique is used throughout the system to indicate that a container can be scrolled. ListView also enables fading edges by default. This means you can see through the default window's background. By default, many Android widgets, ListView included, have a transparent background. Setting the android:cacheColorHint to #00000000 overrides a common issue developers face when customizing the ListView background. Notice the highlighted code at lines 21, 25, 29, 33 and 37. Let's start this tutorial with a simple Linear Layout for the TabHost as our main.xml. For a 5-tabbed app, I have to change 5 ListViews. To further complicate matters, my ListView objects are displayed on a TabWidget. The android:setTextColor directive is no longer available in the ListView object. There used to be in earlier versions of Android, but I'm writing for Froyo and higher. There is no native hook to reach the TextView field used to display the ListView's text. It's no problem changing the background color of a ListView object, but changing the TextColor is a whole other issue. This requires programatically changing every object displayed on the screen on the fly once the user exits the preference screen. In my apps, I like to offer users the preference of choosing a light or dark color scheme as they desire. The default Android ListView object is difficult to work with if creativity is one of your design factors.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |