making own theme

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Postby Emmanuel7 » Mon Jan 19, 2009 1:55 pm

Hum...
Perhaps this is a stupid remark, but why don't you use a button as your list item ?
Emmanuel7
Senior Developer
Senior Developer
 
Posts: 164
Joined: Fri Dec 12, 2008 2:17 am
Location: Paris

Top

Postby darolla » Mon Jan 19, 2009 4:09 pm

oh my gosh, it can be so simple :D

using themeing I removed all ListSelector and ListDivider stuff.

then I placed an xml to the background of each list item (using pressed, selected, focused, ...)

and voila 8)

Greetings,
DaRolla
Attachments
fussball_germany_pressed.png
fussball_germany_pressed.png (22 KiB) Viewed 2742 times
fussball.png
fussball.png (22.16 KiB) Viewed 2743 times
User avatar
darolla
Master Developer
Master Developer
 
Posts: 273
Joined: Thu Sep 25, 2008 5:16 pm
Location: Dortmund, Germany

Postby hit1983 » Thu Jan 22, 2009 9:21 am

Can you share the code to demostrate how to use theme ?
hit1983
Freshman
Freshman
 
Posts: 9
Joined: Mon Oct 06, 2008 8:08 am
Location: BeiJing

Postby darolla » Fri Jan 23, 2009 12:16 am

sure, hit1983 :)

1) styles.xml (removing listselector)
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2.         <style name="Widget.ListView" parent="android:Widget.ListView">
  3.  
  4.                 <item name="android:listSelector">@android:color/transparent</item>
  5.  
  6.                 <item name="android:cacheColorHint">#00000000</item>
  7.  
  8.                 <item name="android:divider">@android:color/transparent</item>
  9.  
  10.                 <item name="android:scrollbarStyle">outsideInset</item>
  11.  
  12.         </style>
  13.  
  14.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


2) themes.xml (routing the style to GreenTheme)
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2.         <style name="GreenTheme" parent="android:Theme">      
  3.  
  4.                 <item name="android:listViewStyle">@style/Widget.ListView</item>        
  5.  
  6.         </style>
  7.  
  8.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


3) manifest (using the GreenTheme)
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2.         <activity android:name=".Country" android:label="@string/app_name" android:theme="@style/GreenTheme">
  3.  
  4.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


4) Country.java
just like every list example, using laender_list_row.xml for each listrow

5) laender_list_row.xml (using btn_list as background for the LinearLayout)
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.         android:layout_width="fill_parent" android:layout_height="wrap_content"
  7.  
  8.         android:orientation="horizontal" android:background="@drawable/btn_list">
  9.  
  10.  
  11.  
  12.         <ImageView android:id="@+id/icon" android:layout_width="wrap_content"
  13.  
  14.                 android:layout_height="wrap_content" android:src="@drawable/france"
  15.  
  16.                 android:layout_gravity="center_vertical" android:paddingLeft="6dip"/>
  17.  
  18.  
  19.  
  20.         <TextView android:id="@+id/country" android:layout_width="fill_parent"
  21.  
  22.                 android:layout_height="fill_parent" android:text="Frankreich"
  23.  
  24.                 android:textSize="16px" android:gravity="center_vertical"
  25.  
  26.                 android:textColor="#ffffff" android:paddingLeft="6dip"/>
  27.  
  28. </LinearLayout>
  29.  
  30.  
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


6) btn_list.xml (different states for the buttons)
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <selector xmlns:android="http://schemas.android.com/apk/res/android">
  3.  
  4.  
  5.  
  6.         <item android:state_focused="true"
  7.  
  8.                 android:drawable="@drawable/btn_list_normal_green" />
  9.  
  10.  
  11.  
  12.         <item android:state_pressed="true"
  13.  
  14.                 android:drawable="@drawable/btn_list_pressed" />
  15.  
  16.  
  17.  
  18.         <item  
  19.  
  20.                 android:drawable="@drawable/btn_list_normal" />
  21.  
  22.  
  23.  
  24. </selector>
  25.  
  26.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


7) just the three graphics as .9.png

I made this graphics for my work, so I won't post them here.

You can use (and rename) android-sdk-windows-1.0_r2\tools\lib\res\default\drawable:
btn_default_selected.9.png
btn_default_pressed.9.png
btn_default_normal.9.png


Greetings,
DaRolla
User avatar
darolla
Master Developer
Master Developer
 
Posts: 273
Joined: Thu Sep 25, 2008 5:16 pm
Location: Dortmund, Germany

Postby darolla » Tue Feb 03, 2009 4:17 pm

did any1 here play around with windowAnimationStyle ?

its completely ignored ???

who helps?

greetings,
darolla

themes.xml
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <item name="android:windowAnimationStyle">@style/Animation.Activity</item>
  3.  
  4.  
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


styles.xml
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <style name="Animation" parent="android:Animation"/>  
  3.  
  4. <style name="Animation.Activity" parent="android:Animation.Activity">
  5.  
  6.     <item name="android:activityOpenEnterAnimation">@anim/fade_in</item>
  7.  
  8.     <item name="android:activityOpenExitAnimation">@anim/fade_in</item>
  9.  
  10.     <item name="android:activityCloseEnterAnimation">@anim/fade_in</item>
  11.  
  12.     <item name="android:activityCloseExitAnimation">@anim/fade_in</item>
  13.  
  14. </style>
  15.  
  16.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


fade_in.xml
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <alpha xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.         android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="1000" />
  7.  
  8.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
User avatar
darolla
Master Developer
Master Developer
 
Posts: 273
Joined: Thu Sep 25, 2008 5:16 pm
Location: Dortmund, Germany

Postby Emmanuel7 » Wed Feb 04, 2009 1:43 am

Isn't Window animation the animation that get activated when you check the
Dev Tools / Development Settings / Window Animation Scale x[1...10]

I tend to mistake it with Transition Animation ( the transition from one activity to another ), so I can't remember if it is set by default.

And by the way, I still don't understand the use of these animations if they are only available on a dev phone. I must have miss something here...
Emmanuel7
Senior Developer
Senior Developer
 
Posts: 164
Joined: Fri Dec 12, 2008 2:17 am
Location: Paris

Top

Postby darolla » Wed Feb 04, 2009 10:52 pm

I downloaded the development.apk sources, but I didnt get the clou.

DevelopmentSettings.java line 79: private IWindowManager mWindowManager;

line 502: mWindowManager.setAnimationScale(which, scale);

this way somehow globally the transition is set.

I need to checkout the source / jar / apk with IWindowManager, I
cannot compile it yet.

I think if we find out how the transition in development.apk is set we
will know more ;)

greetings,
darolla
User avatar
darolla
Master Developer
Master Developer
 
Posts: 273
Joined: Thu Sep 25, 2008 5:16 pm
Location: Dortmund, Germany

Postby darolla » Wed Feb 04, 2009 10:54 pm

here's the apk and the source.zip
Attachments
Development.zip
(69.22 KiB) Downloaded 295 times
Development.apk
(71.39 KiB) Downloaded 155 times
User avatar
darolla
Master Developer
Master Developer
 
Posts: 273
Joined: Thu Sep 25, 2008 5:16 pm
Location: Dortmund, Germany

Postby Emmanuel7 » Thu Feb 05, 2009 1:39 am

You had your answer on the developer forum.

This feature has not been fully implemented, so is deactivated in current SDK :)

"Please don't try to use them until they are officially supported."

Ok, so let's wait !!
:)
Emmanuel7
Senior Developer
Senior Developer
 
Posts: 164
Joined: Fri Dec 12, 2008 2:17 am
Location: Paris

Postby darolla » Thu Feb 05, 2009 8:54 am

excuse me, which answer do you mean or where did I get it? you mean the google groups?
User avatar
darolla
Master Developer
Master Developer
 
Posts: 273
Joined: Thu Sep 25, 2008 5:16 pm
Location: Dortmund, Germany

Postby Emmanuel7 » Thu Feb 05, 2009 8:46 pm

Yes, I meant the Android developers google group...

Sorry for being unclear...

here's the link :

http://groups.google.com/group/android- ... bb63ad1d35
Emmanuel7
Senior Developer
Senior Developer
 
Posts: 164
Joined: Fri Dec 12, 2008 2:17 am
Location: Paris

Postby pmskiran » Thu Aug 20, 2009 11:54 am

I am not able find this path (android-sdk-windows-1.0_r2) \tools\lib\res\default\values in styles.xml and themes.xml.

in this sdk :-- android-sdk-mac_x86-1.5_r2 (This is mac supported sdk.)

Please do help for me..
Kiran PMS
pmskiran
Junior Developer
Junior Developer
 
Posts: 12
Joined: Fri Jul 31, 2009 10:44 am
Location: India

Postby arnouf » Wed Dec 23, 2009 12:11 pm

hi all,

I'm trying to change the default option menu backgroud, when user select it...
Do you know if it's possible using style/selector and theme ?

For now, I don't success :(
arnouf
Developer
Developer
 
Posts: 28
Joined: Mon Jan 21, 2008 9:07 pm

Postby Crw » Wed Jan 13, 2010 8:16 pm

I've used the stuff above and it seems to be working nicely @ application load.The only problem i face is that on-the-fly themes switching doesn't work correctly - when i select other scheme at the first time it changes (but w/o background), then doesn't change at all. I'm using
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. setTheme(R.style.<Theme Name>);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

followed by
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. setContentView(R.layout.<Activity Name>);                      
  2.  
  3.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4

Did i miss something?
[spoil]
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. @Override
  2.  
  3.     public void onCreate(Bundle savedInstanceState) {
  4.  
  5.         super.onCreate(savedInstanceState);
  6.  
  7.         setContentView(R.layout.theme_main);
  8.  
  9.        
  10.  
  11.        
  12.  
  13.         Button but = (Button)findViewById(R.id.butt);
  14.  
  15.         but.setOnClickListener(new OnClickListener(){
  16.  
  17.  
  18.  
  19.                         @Override
  20.  
  21.                         public void onClick(View arg0) {
  22.  
  23.                                 // TODO Auto-generated method stub
  24.  
  25.                                 setTheme(R.style.RedTheme);
  26.  
  27.                                 setContentView(R.layout.theme_main);                           
  28.  
  29.                         }});
  30.  
  31.        
  32.  
  33.         Button but2 = (Button)findViewById(R.id.butt2);
  34.  
  35.         but2.setOnClickListener(new OnClickListener(){
  36.  
  37.  
  38.  
  39.                         @Override
  40.  
  41.                         public void onClick(View arg0) {
  42.  
  43.                                 // TODO Auto-generated method stub
  44.  
  45.                                 setTheme(R.style.GreenTheme);
  46.  
  47.                                 setContentView(R.layout.theme_main);                           
  48.  
  49.                         }});
  50.  
  51.        
  52.  
  53.     }
Parsed in 0.037 seconds, using GeSHi 1.0.8.4
[/spoil]
Crw
Freshman
Freshman
 
Posts: 2
Joined: Wed Jan 13, 2010 10:52 am

Re: making own theme

Postby mattq » Mon Jun 21, 2010 11:24 pm

I posted a pretty in-depth tutorial about applying themes here: http://www.androidengineer.com/2010/06/ ... tions.html
mattq
Freshman
Freshman
 
Posts: 2
Joined: Mon Jun 21, 2010 11:17 pm

Top
PreviousNext

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 8 guests