im trying to use this : https://stackoverflow.com/a/24633486/4707917
but it didnt work for kitkat...
and i need only colorPrimaryDark like Lollipop in kitkat or older sdk.(Without any Library !)
ide:android studio.
any Solution ?
The information provided below is based on this blog post by someone that works for the Android team.
You can do this by using the android support libraries. First add a dependency on the v7 support library to your build.gradle file:
dependencies {
...
compile "com.android.support:appcompat-v7:21.0.+"
}
You can now use the colorPrimaryDark property in your themes.xml file. All you need to do is make sure that your style inherits from an appcompat style, for example: parent="Theme.AppCompat.Light"
Please note that this will only affect the styles of the action bar.
Related
when I update to android 3.1.3 the design screen not showing anything I googled it and found the solution to change the appTheme parent to
Base.Theme.AppCompat.Light.DarkActionBar
instead of
Theme.AppCompat.Light.DarkActionBar
and worked perfectly.
my question is
why doesn't it work with default one and what is the difference between two themes?
There shouldn't be any difference. If you look up style definition in values.xml of your appcompat library, you can see that Theme.AppCompat.Light.DarkActionBar just extends Base.Theme.AppCompat.Light.DarkActionBar and nothing else.
The problem seems that there was a bug with how Android Studio handled some versions of the support library. You can find a more detailed answer here:
Failed to load AppCompat ActionBar with unknown error in android studio
Anyway, after updating Android Studio to 3.2 and Gradle to 4.6, the problem is gone.
I'm trying to learn Android through the tutorials at TheNewBoston.com.
In the tutorial, I'm supposed to switch to the material light theme. That's when I get the error. It says:
Missing styles. Is the correct theme chosen for the layout?
Here's a screen shot:
Here's what I've tried:
I've tried switching out of Android API 23, N preview for a lower
API
I've tried changing code in the styles.xml file from
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
to
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
I've tried invalidating the cache and restarting.
Nothing seems to be working. I'm very new at Android and just want to get the IDE set up correctly. I also get this message on startup and I think it's related to the error:
Change your layout Preview from API N to API 23. also select target and compile sdk version 23.
Change Compile sdk version and Build SDK version
Have you added this line to your build.gradle file under dependencies
compile 'com.android.support:appcompat-v7:23.2.1'
Note that the support version number might be higher for you. Add below line too to your depedencies
compile 'com.android.support:design:23.2.1'
In theme dropdown at the top of the graphical display of layout. change Theme.
check your theme in style than choose it in the layout too
OR
changed from Holo to Theme and the layout displayed and error disappeared.
check this answer for more detail
Reinstalling Android Studio and right-clicking the shortcut to run the program as administrator sorted out the problem.
I am just a beginner to android app development. When i created a new project on Android Studio 1.1.0,
it gives up this error
"rendering problems
The following classes could not be found android.support.v7.internal.widget.ActionBarOverlayLayout"
Now i have searched about this on google, and i found possibly 3 solutions given by most of the people.
They say:
Either change the api (from preview window pane) from 22 to 21, or
Change the App Theme from "Project Theme" to any other theme.
be sure to have imported right appcompat-v7 library in your project structure -> dependencies,
Refer these steps:
Add the support library feature project identifier to the dependencies section. For example, to include the appcompat project add compile "com.android.support:appcompat-v7:18.0.+" to the dependencies section, as shown in the following example:
dependencies {
...
compile "com.android.support:appcompat-v7:18.0.+" }
Note: My android support lib is up-to-date (installed it using SDK Manager).
Following first two steps, removed the error. But I feel that these are not the permanent solutions, the Second step seems just like a temporary workaround. I have doubts about the First step also, that if to remove the error, we change api from 22 to 21, then at the end, our app wont work in Android 5.1.1(API 22), it would be restricted to Android 5.0.1 and below only (API 21). Are my doubts valid?
Regarding the third step, is it the permanent solution to this problem?
P.S : Sorry for mismatching tags, wasn't allowed to add exact tags due to site reputation
Fix res/values/styles.xml like so:
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar"/>
Detailed explanation as requested: Theme.AppCompat.Light.DarkActionBar is a subclass of the superclass Base anyway. Ctrl+click (Android Studio) on it and you will be taken to the source:
<style name="Theme.AppCompat.Light.DarkActionBar" parent="Base.Theme.AppCompat.Light.DarkActionBar" />
We didn't change anything, we just defined it more precisely.
This is a known bug since Android Studio build 1.1 (it is also still in 1.2 and 1.3 preview). Switching the preview's API level from 22 to 21 fixes the for most people. While waiting for a fix you could try it as well.
Originally answered here : Rendering problems in Android Studio v 1.1 / 1.2
Just reposting
Modify src/res/values/styles.xml
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar"></style>
Then select API22, you'll find this problem fixed!
After this error, I'm using :
API-22 Android 5.1.1 and still this problem exist.But you can at the top of the android studio toolbar, Choose:
Material Light -> Material Light
and then you can see the preview with Toolbar and light theme.
Hope this helps.
I fixed this problem by switching to the Holo Dark theme, then back to the App theme. I just clicked the button above the viewer that says App theme next to the rotate view in Android Studio. About 10% of the time, that alone doesn't work and I also have to change the API of the viewer from 22 to 19.
No idea why this works, but the suggestions provided above did not work for me.
You don't need to change the theme. Maybe your're extending ActionBarActivity (deprecated) instead of just Activity. Change it, and build the project.
If you do change the activity from ActionBarActivity to just Activity, don't forget to import the Activity itself. That is
import android.app.Activity
It sucks but hey, it's their fault and not ours.
Also you can simply change the theme by pressing the "AppTheme" and choose Holo.Light.DarkActionBar. It updates the styles.xml file automatically.After that, rebuild the project.
I did all these and it works for me though i think them guys at Google and IntelliJ should do something about this rendering problem since we have been told to move from Eclipse to Android Studio
I am using android studio 1.0
Trying to make material design app that is compatible with older versions of android too...
Made new blank project, Added compile 'com.android.support:appcompat-v7:21.0.3' dependency to the gradle file
Still no luck :/
Anyone please help me out....
Create the values-v21 folder and create styles.xml
Inside styles.xml choose Material Theme.
It was in older versions of Android Sudio. In Android Studio 1.0 you have to create by yourself.
Check your SDK version update it to Android 5.0 (Api 21).
And you will be good to go.
Maintain material design Compatibility to older version of Android by following this link.
https://developer.android.com/training/material/compatibility.html
Cheers..
If you want to make a material design app that is compatible with older versions of Android, you really need to include the library
'com.android.support:appcompat-v7:21.+'
And make some changes to your app. This link shows a pretty good how to
http://android-developers.blogspot.com.br/2014/10/appcompat-v21-material-design-for-pre.html
The most importante change is the new Toolbar, that you can eather include in every layout you want, or work with "ActioBarActivities". Again, reading this official blog post will help you.
But, as the title of your question said, you can create a folder called "values-21" and put a new "style.xml", that will target only Android Lollipop. In this file, you can extend android:Theme.Material and use some features that are only present in Android 5.0, like ripples and some animations.
I'm new in Android programming. I just wanna how to create a ActionBar for android 2.2 version.
You can use ActionBarSherlock. It's an open source library that emulates the exact features and design of the ActionBar.
Please see: http://actionbarsherlock.com
Google uses this as well in a number of applications.
yes ActionBarSherlock is best option,
Please See https://github.com/JakeWharton/ActionBarSherlock
Use AppCompat library from com.android.support.
Google has released com.android.support to support things like this on older devices
Add the dependecy in build.gradle (it's NOT in the root directory) inside dependencies{...}
dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
}
And change your theme to Theme.AppCompat or Theme.AppCompat.* (The wildcard represents more styles inside Theme.AppCompat