Setting Up the Action Bar tutorial in Android Atudio - android

Theme.Holo is used in the tutorial http://developer.android.com/training/basics/actionbar/setting-up.html
I'm using Android Studio, and the Theme.AppCompat.Light.DarkActionBar is the default style used in the styles.xml
The emulator gives an error Unfortunately, Action Bar has stopped if I comment out AppCompat theme in styles.xml and add style name="AppTheme" parent="#android:style/Theme.Holo.Light.DarkActionBar
How can Android Studio be setup so that Holo is the default theme, or how can the theme be changed to match the tutorial?

Change the default code in styles.xml to:
<style name="AppTheme" parent="android:Theme.Holo.Light">
That does it right? Let me know.

Related

color of status bar in Android Studio

I am Struggling to change the color of the status bar for each activity.
I have tried the create theme and style listed in posts on this site to no avail.
How can I make each activity have a status bar of different color?
You can change it by setting the android:statusBarColor or android:colorPrimaryDark attribute of the style you're using for your app in styles.xml.
(android:statusBarColor inherits the value of android:colorPrimaryDark by default)
For example (since we're using an AppCompat theme here, the android namespace is omitted):
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimaryDark">#color/your_custom_color</item>
</style>
On API level 21+ you can also use the Window.setStatusBarColor() method from code.

Changing status bar icon color

I have received a design spec. in which the status bar icons' color is to be changed completely. I know I can change the status bar color in theme, however that is not my question. I want to override the icon color/icons themselves as shown in the image attached.
I searched a bit but could not find a way to do it.
I am aware that as a last resort, I can change the existing status bar icon tintcolor the following attribute in my app theme.
<item name="android:windowLightStatusBar" tools:targetApi="23">true</item>
You can change it by setting the android:statusBarColor or android:colorPrimaryDark attribute of the style you're using for your app in styles.xml.
(android:statusBarColor inherits the value of android:colorPrimaryDark by default)
For example (since we're using an AppCompat theme here, the android namespace is omitted):
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimaryDark">#color/your_custom_color</item>
</style>
On API level 21+ you can also use the Window.setStatusBarColor() method from code.
<item name="colorPrimaryDark">#color/your_color</item>
will only be visible in Lollipop and greater than Lollipop(API) devices. P.S. you need to have Theme.AppCompat as your base/main theme

How do i change my default actionBar color?

I am running the latest eclipse with the latest Android support library, API 23. by default, the support library along with material design gets added to a new project as far as i know (Compile with API 23).
But i want to change the ActionBar's color, earlier it was not possible on API <11 as it used android's built in library. now i am sure they added action bar in the support library as i tested my project on an android 2.3 device and i see the action bar, so compatibility is not an issue here.
So how do i change my action bar and button's colors?
EDIT::The suspected duplicate does Not solve my problem, i have tried that already, it gives me api level error when i define theme in the styles.xml. i have included the link in my question already.
Edit your styles.xml file. The colorPrimary will be your action bar color and the colorPrimaryDark is the status bar color.
Note: Make sure this theme is set as your activities theme in your manifest.
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimaryDark</item>
<item name="colorPrimaryDark">#color/colorPrimaryDarkDark</item>
</style>

App crashes on changing theme under styles

My Android App :
Target API:22
Min API:15
Device run on :API level 22
I don't understand this whole theme concept ,
In my manifest.xml ,I have set android:theme="#style/AppTheme"
and all activities use this theme
Now my understanding is that they all use the theme called AppTheme which I can now define by extending other themes inside my styles.xml
In my styles.xml
I have this
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
My understanding is that AppCompat themes allow us to use newer(say material themes) on older devices also .
I run this app on API Level 22 and API Level 15 , it works fine
Now when i change it to
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material">
<!-- Customize your theme here. -->
</style>
</resources>
It gives a warning saying this theme can be used only on API 21 or above which is correct , now when I ignore the warning and run it in on API 22 it crashes.
Why?
Also I tried to make AppTheme's parent as Holo , Light etc ,all of them crash the App , why , please explain?
All of these end up crashing the App
<style name="AppTheme" parent="android:Theme.Translucent">
<style name="AppTheme" parent="android:Theme.Holo">
Why do these not work , Holo was introduced in 15 right?
I am using 22 ,
and can you please elaborate the difference between
Theme....., BaseTheme....,Android..... themeName
And i am running android studio 1.3 and using the latest versions(Stable) of the SDK,SDK build and SDK-Platform tools.
Thank you !
Sorry , I found the issue , My activity was extending AppCompatActivity instead of the general activity ,I get it now
When ever working with custom styles you have to take care of the parent you are providing. Try to change the parent theme and it might solve your problem.

Android studio preview pane not rendering ActionBar?

I'm running the latest version of android studio ,Problem is the preview pane does not render the ActionBar when any of the AppCompat themes are used, if i change the theme of the preview pane it works fine(Not change actual theme) ,but is there any discepency in doing this,
my styles.xml is as follows
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
when the preview pane is set to AppTheme ,the ActionBar ain't shown ,however it works fine in my device and AVD,
As you can see this makes it hard to debug and test the ActionBar
Please suggest some fix to this and how exactly does a AppCompat theme differ from an ordinary one?,I'm just an android beginner .
Thanks!
It is a bug: https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=78944
Unfortunately it is low priority.
Update: set the preview to API 22
In my styles.xml I had
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
had to change it to just
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
There is culprit in your MainActivity(which ever your activity) when your are using app.compact.v7 your are supposed to extend ActionBarActivity instead Activity

Categories

Resources