A few questions about styles

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

A few questions about styles

Postby BGH » Tue Apr 14, 2009 3:03 am

I have a table layout that I add rows to dynamically. The rows contain textviews. I am trying to create styles to apply to the textviews that are inserted into the table rows but I'm experience a few quirks.

From what I can gather I should be able to create a new textview that uses a style by using

Textview tv = new TextView(this, null, R.style.score_team);

But this doesn't seem to work. It creates the textview but the style isn't applied to it. I have to manually set the style by using

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Textview tv = new TextView(this);
  2.  
  3. tv.setTextAppearance(this, R.style.score_team);
  4.  
  5.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

Also

I can't get the style to apply gravity. If I put
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <item name="android:gravity">center</item>
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


it doesn't apply the gravity (all the other attributes of the style are applied). I have to set the gravity manually by doing the following.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Textview tv = new TextView(this);
  2.  
  3. tv.setTextAppearance(this, R.style.score_team);
  4.  
  5. tv.setGravity(Gravity.CENTER);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


Which works.

Any clues as to either problem?
User avatar
BGH
Junior Developer
Junior Developer
 
Posts: 23
Joined: Thu Feb 12, 2009 3:51 am
Location: Melbourne, Australia

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Exabot [Bot] and 4 guests