I just wanted to give my actionbarsherlock tabs another color. Therefore, I found this interesting article: Styling the Actionbarsherlock tabs
Now, my problem is that for me it only works for API level before 11. What am I doing wrong? I implemented the code from the solution just like that.
One other thing that I did, was increasing my API level (from 7 to 11) because this line from the code in the article
<item name="android:actionBarTabBarStyle">#style/Theme.app.tabbar.style</item>
produced this error:
android:actionBarTabBarStyle requires API level 11 (current min is 7)
Any ideas?
For just API 11+ you can create a folder in res called values-v11 and make a style file in there, then only those styles will be applied if the API is level 11 or greater.
Related
I'm using com.android.support:appcompat-v7:22.2.0 to make Lolipop material design on pre-Lolipop devices. The problem is that widgets (example EditText) are displaying different views with different parameters on different API.
Question is how to make it all looks the same on all API 15 and above?
Example here (different bottom line, margin between text and line etc.):
I think that I found solution.
AppCompat generates proper look during inflating layout.
If API < 20 it generates look like newest API (ex. 22).
If API >= 21 it generates look depending on API.
Don't look at preview in XML (my image is from previews). Open emulator and check by yourself how it will looks on device.
Hope it helps someone in future.
I want to use the
style="?android:attr/borderlessButtonStyle"
for my buttons. This requires min. API level 11. I want my app to be min API level 9. So I used the styles tag in the default layout folder and createt the folders res/layout-v9 and res/layout-v10 with the same xml-files as in the default layout folder - except for the style tag. I still get the minimum API level 11 error for the xml file in layout folder.
How can I avoid the error and apply the style-tag for API level >= 11 but not for API level < 11?
borderlessButtonStyle is part of the Holo theme, which is why it's not available below API Level 11.
You can however use that theme on earlier API levels by incorporating the HoloEverywhere project into your app.
If that's not what you're looking to do, you'll need to create a custom selector in your drawable folders and use that for button styling instead.
Did you look at the "Providing Alternative Resrouces" section in this article?:
http://developer.android.com/guide/topics/resources/providing-resources.html
Basically you add a suffix (called a "qualifier" in the linked article) "-v11" for specific API levels (so you would have a special folder named layout-v10, layout-v9, etc., each with the desired layout file in that folder). I'm not sure if there's a way to specify a range of API levels, though (i.e., less than 11, vs. greater than 11).
Just as an aside: this is what's actually going on with providing differently sized icons with the same name: you'll notice that Android projects created in eclipse have drawable-ldpi, drawable-mdpi, etc., as well as the "catch-all' drawable folders as a means for specifying alternative resources.
I'm just new in android.. i just wanna ask how to create a actionbar ??.. without using a import com.markupartist.android.widget.Actionbar that comes from a project that I have been downloaded.. Thank you .. I'm using a 2.2 version
You'll get a ActionBar by default, if your app runs HC+ (and you use the holo theme). However, since the ActionBar got introduced with HC (API Level 11) you have to use ActionBarSherlock, if you want to use it on pre HC devices.
From the Android Developers guide:
Beginning with Android 3.0 (API level 11), the action bar is included
in all activities that use the Theme.Holo theme (or one of its
descendants), which is the default theme when either the
targetSdkVersion or minSdkVersion attribute is set to "11" or greater.
Thus you simply need to set
<uses-sdk android:minSdkVersion="11" />
or
<uses-sdk android:targetSdkVersion="11" />
in your AndroidManifest.xml. You can, of course, set either to higher than 11 as needed, but 11 is the minimum for automatically including the ActionBar.
If you want to use ActionBar in your project, then just download it from this link
Download Actionbar library project
Now import this project into your eclipse.
After that set it as library in your project.
Its done...
I have an app with 4 tabs and icon images for each tab. I am using TabActivity and TabHost.
setIndicator ("Example", getResources().getDrawable(R.drawable.tabicon));
The app works fine with API 8 and when I have the following in the manifest file :
but when I explicitly put the targetSdkVersion="16" in the manifest, the tab icons are not showing.
How can I preserve the Tab icons without changing a bunch of code? Is there a Tab icon code sample I can follow for API 16?
thanks a bunch !!
TabActivity and TabHost are deprecated in API 11.
Instead use the ActionBar with Tabs (Example here), for compatability with API versions lower than 11 use ActionBarSherlock.
Don't use old APIs anymore!
I want to build a tabbed interface, so I took the Tabs3 view from the API demos sample project, however for some reason the Holo theme is not being applied to my app It should look like this But it looks like this.
This is the relevant bit in my manifest:
<application
android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:theme="#android:style/Theme.Holo.Light">
<activity android:name="Tabs"
android:label="#string/app_name" >
At this point all I have done is copy over the Tabs3 class (renamed to Tabs), List1, List8 and Controls1, along with the related layouts and strings.
Thanks for the help!
You use the wrong tabs. Here is a full tutorial how to use ActionBar.Tab. Click me!
Remind, ActionBar.Tab is only available on API Level 11 or higher, if you want to support Android API Level 10 (Android 2.3) or lower, you have to use ActionBarSherlock.
The Holo theme is only available in Android since API Level 15. If you want to use the Holo theme on lower API levels you should take a look at HoloEverywhere.
Holo Theme is available for API level 11 and up. That might be the reason for it not working. If anything you can use ActionBarSherlock for lower API levels.