Add a cute background

Task for today: how to add a background to the app. Something simple but colorful.

Let’s gather sources:

1. Free Icons http://ntt.cc/2010/08/04/350-fresh-and-elegant-free-icons-for-android.html

2.  Round buttons http://blog.stylingandroid.com/archives/55#more-55

3.  Maybe this is it? Let’s try.

<style name="dialog_footer">
	<item name="android:background">@drawable/dialog_footer</item>
	<item name="android:paddingTop">5dp</item>
</style>
Somehow Padding is not taking effect. it appears constant.

4. EditText style. Adding this line to my styles for edit boxes is creating round edge, nice look actually.  Accepting.

<item name=”android:background”>@android:drawable/editbox_background</item>

5. next let’s try  android:background=”@android:drawable/gallery_image” for FrameLayout. What would it do? I added it to my ScrollView and it makes my view elevated , with a grey-ish shadow all around. Nice. I’ll try with another image but I am accepting it.

Added padding attribute to see wider margin on the scroll view but it stays constant. Boo.  Oh I see, padding is for Inside! of the area, how far of offset children.

Added background to the LinearLayout but it colors all the area inside of the layout.

6. Maybe I have to set window background, not a layout background.

getWindow().setBackgroundDrawableResource(R.drawable.my_drawable);
Something funky with using drawable for background, seems that the image has to be some certain size and pretty big. Weird. Later I have to lookup how to use tiled image , maybe that will avoid creating large image with unknown size.

Bottom line: background attribute is for inside of the View. Padding is for inside of the view.  Android:drawable has several images that could be useful. 


 

Advertisements

One thought on “Add a cute background

Leave a Reply

Fill in your details below or click an icon to log in:

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