Style resources example

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Style resources example

Postby s.semeria » Fri Apr 11, 2008 9:12 am

Hi all,

can anybody clarify a bit how style resources work?? They looks like CSS if I understood well, so they seem quite interesting but It's not very clear to me how they should be used to avoid styling components in code.

Could anybody provide some examples?

s.semeria
s.semeria
Junior Developer
Junior Developer
 
Posts: 23
Joined: Mon Jan 28, 2008 10:18 am
Location: Italy

Top

Postby plusminus » Tue Apr 29, 2008 7:00 pm

Hello s.semeria,

create a file, like "my_menu_styles.xml" in /res/values :
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <resources>
  3.     <style name="menubutton_quickinfo_textstyle">
  4.         <item name="android:textSize">22sp</item>
  5.         <item name="android:textStyle">bold</item>
  6.     </style>
  7. </resources>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


The use it in any View you like:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.         <TextView
  2.                 android:id="@+id/tv_menu_button_quickinfo"
  3.                 style="@style/menubutton_quickinfo_textstyle"
  4.                 android:layout_width="fill_parent"
  5.                 android:layout_height="wrap_content"
  6.                 android:textAlign="center"
  7.                 android:text="@string/menu_whereami" />
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby s.semeria » Wed Apr 30, 2008 9:33 am

Great,

thanks a lot for your help :D

Regards,

Stefano
s.semeria
Junior Developer
Junior Developer
 
Posts: 23
Joined: Mon Jan 28, 2008 10:18 am
Location: Italy

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 5 guests