we're developing android application has several different tabs. we've been trying apply theme entire application, , we've tried applying theme specific activities. neither has effect.
i have style-file:
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="recapmain"> <item name="android:buttonstyle">@style/recapbutton</item> <item name="android:textviewstyle">@style/recaptext</item> </style> <style name="recapbutton" parent="android:style/widget.button"> <item name="android:textsize">30sp</item> <item name="android:background">#ff0000</item> </style> <style name="recaptext"> <item name="android:textsize">30dip</item> <item name="android:textcolor">#ffffff</item> </style> </resources>
the application tag in manifest file looks this:
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/recapmain"> <activity android:name="appname" android:label="@string/app_name" android:theme="@android:style/theme.notitlebar"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity>
this doesn't work. application not react theme. if set specific view use 1 of styles, it's works perfectly. so, can in xml file activity:
<button android:id="@+id/overviewbuttonyears" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/years" android:onclick="years" style="@style/recapbutton" />
that style button appropriately.
we've tried applying theme specific activity tag, no result.
now, does work, removing intent-filter-tag application tag, , putting in activity tag, this:
<activity android:name=".policytab" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity>
that starts specific activity only, , have appropriate theme.
my question then, is, why? we've gussed has tabs, since starting 1 activity enables theme. have work with tabs?
if wany main application theme android:theme="@android:style/theme.notitlebar"
customized control styles, should extend theme preferences:
<style name="recapmain" parent="@android:style/theme.notitlebar">
this line adopt styles of parent theme recapmain
, , inside can write own preferences (as have buttonstyle
, textviewstyle
).
inside androidmanifest.xml
set application theme custom style:
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/recapmain">
update
styles.xml should contain:
<style name="recapmain" parent="@android:style/theme.notitlebar"> <item name="android:buttonstyle">@style/recapbutton</item> <item name="android:textviewstyle">@style/recaptext</item> </style> <style name="recapbutton" parent="android:style/widget.button"> <item name="android:textsize">30sp</item> <item name="android:background">#ff0000</item> </style> <style name="recaptext" parent="android:style/widget.textview"> <item name="android:textsize">30dip</item> <item name="android:textcolor">#ffffff</item> </style>
Comments
Post a Comment