Android Tech

The more we share, the more we get

TabView (Part 8) – Set background of tabwidget with shape drawable


You can use the example in previous post.

Android define some Drawable Resources which use use to build your own style for application. Here I want to illustrate for Shape Drawable. This is a generic shape defined in XML.

Here is the syntax of it:

We will use this structure in example below.

1. Create a drawable resource for this example like this

<?xml version=”1.0″ encoding=”UTF-8″?>
<shape xmlns:android=”http://schemas.android.com/apk/res/android&#8221;
android:shape=”rectangle” >
<gradient android:startColor=”#505050″
android:centerColor=”#101010″
android:endColor=”#101010″
android:angle=”270″/>
</shape>

2. Set this drawable resource as background for TabWidget

android:background=”@drawable/tabwidgetbk”

And the final result will like this:

You can download the source code from here

If you modify the attribute “android:angle” to 0, the result will like this:

You can download the source code from here

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: