We are trying to build an Android App for Samsung Galaxy Tablets. Is there a way we can increase the height of the ActionBar? We are using Android 3.1 API 12.
You can apply a custom theme to your application.
Create styles.xml in your res/values/ directory and add something like this:
<style name="CustomTheme" parent="android:style/Theme">
<item name="android:actionBarSize">#dimen/action_bar_default_height</item>
</style>
Then create dimens.xml in your res/values/ directory and add something like this:
<resources>
<dimen name="action_bar_default_height">55dp</dimen>
</resources>
Then in your application manifest set the theme of the application like this:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:logo="#drawable/ic_launcher"
android:theme="#style/CustomTheme" >
...
</application>
You will need to create a custom Action Bar.
Here is a good tutorial
Creating a custom Action bar
Also here is a good example from the dev site.
Android Action Bar
Related
I managed to get this done a few days back but now I've forgotten what steps I took to make it work.
I've generated a custom widget theme from http://android-holo-colors.com
I've copied it to my res folder. I need to know what to change in the manifest and the styles.xml file to make it work with my app. I've tried a lot of different things but the theme either doesn't change or generates and xml error.
manifest.xml
<activity
android:name="com.yourapp.app"
android:label="#string/app_name"
android:screenOrientation="landscape"
android:theme="#style/Theme.YourTheme"
...
</activity>
res/values/styles.xml
<style name="YourTheme" parent="android:Theme.Light">
...
</style>
When I created new Android application in Eclipse.In its AndroidManifest.xml the theme set to application isandroid:theme="#style/AppTheme"& style.xml is as follows.
<resources>
<style name="AppTheme" parent="android:Theme.Light" />
</resources>
& my screen appears like this.
I want to remove the TitleBar from app but want to show the theme of Android 4.1's.
For this I tried
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Light.NoTitleBar" >
Now my screen appears like this the TitleBar is removed but theme has changed.
Please help me to sort out this issue.
Use this instead : #android:style/Theme.Holo.NoActionBar.
Try out putting this in your manifest.
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
Why is there a difference between theme defined in AndroidManifest.xml and theme taken from styles.xml?
1) AndroidManifest.xml:
<application ... android:theme="#android:style/Theme.Black">
2) AndroidManifest.xml
<application ... android:theme="#style/AppTheme">
styles.xml
<resources>
<style name="AppTheme" parent="#android:style/Theme.Black" />
</resources>
1st setting gives black theme and no action bar. 2nd has dark action bar and light menu.
EDIT : options 1) and 2) - notice Menu and ActionBar
EDIT 2:
Why doesn't the 2nd option actually use the AppTheme (Theme.Black) ? (tested on SGS3)
You probably have another styles.xml file, perhaps under a directory like "values-v11", that is defining the #style/AppTheme differently than #android:style/Theme.Black and taking precedence over the file you're viewing/modifying.
#android:style/Theme.Black implements the exact theme implemented by Android (or device manufacturer). However, #style/AppTheme allows you to perform custom modification in your theme which actually extends the original Theme.Black from android, and in order to perform custom modifications, you use style resources.
In simple words, its just like using Activity class or YourOwnActivity class which extends Activity with extra features inside.
Styles.xml enables you to create your own themes. In AndroidManifest, you set the theme you want for an app or activity. You may want to use a system theme or your own. You can also extend other themes as you're doing setting "parent" attribute. For further information, check this out:
http://developer.android.com/guide/topics/ui/themes.html
You should try to put:
<resources>
<style name="AppTheme" parent="#android:style/Theme.Black" />
</resources>
in a xml file called res/themes.xml
How can I set the dark holo theme in my app?
At this time I got this:
<style name="AppTheme" parent="android:Theme.Holo.Light" />
But when I change it to:
<style name="AppTheme" parent="android:Theme.Holo.Dark" />
I get an error error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Dark'.
How to solve the problem?
change parent="android:Theme.Holo.Dark"
to parent="android:Theme.Holo"
The holo dark theme is called Holo
By default android will set Holo to the Dark theme. There is no theme called Holo.Dark, there's only Holo.Light, that's why you are getting the resource not found error.
So just set it to:
<style name="AppTheme" parent="android:Theme.Holo" />
According the android.com, you only need to set it in the AndroidManifest.xml file:
http://developer.android.com/guide/topics/ui/themes.html#ApplyATheme
Adding the theme attribute to your application element worked for me:
--AndroidManifest.xml--
...
<application ...
android:theme="#android:style/Theme.Holo"/>
...
</application>
In your application android manifest file, under the application tag you can try several of these themes.
Replace
<application
android:theme="#style/AppTheme" >
with different themes defined by the android system. They can be like:-
android:theme="#android:style/Theme.Black"
android:theme="#android:style/Theme.DeviceDefault"
android:theme="#android:style/Theme.DeviceDefault.Dialog"
android:theme="#android:style/Theme.Holo"
android:theme="#android:style/Theme.Translucent"
Each of these themes will have a different effect on your application like the DeviceDefault.Dialog will make your application look like a dialog box. You should try more of these. You can have a look from the android sdk or simply use auto complete in Eclipse IDE to explore the various available options.
A correct way to define your own theme would be to edit the styles.xml file present in the resources folder of your application.
I have tried both Theme.DeviceDefault and Theme.Black in my styles.xml, and both make my 2.1 emulator become black correctly, but on the 4.1 emulator it stays white...am I doing something wrong?
<resources>
<style name="AppTheme" parent="android:Theme.Black" />
</resources>
PS: I presume the drop-down for "Theme" at the top of the Graphical Layout is just showing me what it would look like, it's not some kind of setting that's going somewhere (for the app)?
The Android system always chooses the most special values folder that fits best to your device.
As example if you have a folder values and another folder values-v14 the Android system takes resources from the latter if the device is v14 or newer.
Please refer to the Android documentation for more information.
1.create new folder under res -> values-v13
2.create file style there and add this style :
<style name="AppTheme" parent="android:style/Theme.Holo.Light">
in your manifast use this style for your application like this
<application
android:name=".MainApp"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
that way on ICS version you use the Holo.light theme and pre ICS use the default you already created
Setting it via styles doesn't actually work, but if you set it explicitly for application it works.
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black" >
By default 4.0 and 4.1 give us white background but you can change it to black I face the same problem some days ago, if your project theme is set to be black then probably you change the Title while creating project to "Main" by default its "MainActivity" but if you change it to "Main" it will give you black backgrount/
I don't know my answer is relevant to your question or not but i think you talking about this if i am not wrong.