Custom styling for Icecream sandwich and older

bluedude

Well-Known Member
Licensed User
Longtime User
Hi,

Did some experiments today with custom styling for ICS (Icecream Sandwich) and supporting older versions. You can use the resources structure for that, I explain below.

In your B4A project folder created the following folder structure in Objects\res:

values\styles.xml
values-v11\styles.xml

The styles.xml file in values contains this:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme" parent="@android:style/Theme.Light">
</style>
</resources>

Save and make the file readonly.

The styles.xml file in values-v11 contains this:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
</style>
</resources>

Save and make the file readonly.

Now use the new manifest editor of B4A 1.8 and add:

SetApplicationAttribute(android:theme, "@style/MyTheme")

Above sample will simply use Holo.light on API v11 devices and a normal light theme on older devices. You can play around with these.

Make sure to compile with high enough API (configure paths) and make sure this line is in the manifest:

<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="11"/>

Have fun with this simple first step to a custom theme.
 

cmweb

Active Member
Licensed User
Longtime User
thanks for this tip!

It works very well, but I have a problem on a Motorola Xoom tablet device.

The App menu is not available there.

On a Galaxy Nexus (with ICS) the menu works well. On Android 2.x Devices as well, but it seems that there's no menu on Android 3.x (Honeycomb) devices.

Any ideas how to fix that?

Best regards,

Carsten
 
Upvote 0

cmweb

Active Member
Licensed User
Longtime User
Okay, I think I found the problem...

Honeycomb seems to require an activity title to show the menu icon in that...

My app didn't show the title...

Best regards,

Carsten
 
Upvote 0

cmweb

Active Member
Licensed User
Longtime User
Unfortunately, it's still not working.

Not only on Honeycomb, also on ICS there's no menu button.

Any ideas, why the menu button disappeared?

Best regards,

Carsten
 
Upvote 0

cmweb

Active Member
Licensed User
Longtime User
Found this:

Say Goodbye to the Menu Button | Android Developers Blog

It's about the action bar on Android 3.x and beyond devices.

That means, that

<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="11"/>

would force a ICS handheld to show the menu bar, but not a tablet device with Android 3.x or higher.

The solution ist to remove the "android:targetSdkVersion="11"" from the line above.

Then, Android will add the menu button to Android 3.x/4.x smartphons and tablets.

Best regards,

Carsten
 
Upvote 0

Woinowski

Active Member
Licensed User
Longtime User
Then would it be new style

Found this:

Say Goodbye to the Menu Button | Android Developers Blog

It's about the action bar on Android 3.x and beyond devices.

That means, that

<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="11"/>

would force a ICS handheld to show the menu bar, but not a tablet device with Android 3.x or higher.

The solution ist to remove the "android:targetSdkVersion="11"" from the line above.

Then, Android will add the menu button to Android 3.x/4.x smartphons and tablets.

Best regards,

Carsten
Comparing your hint with the blog post you link to, does your trick lead to a consistent sdk>=11 style?
 
Upvote 0
Top