I don't have a separate folder called values v21 - android

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.

Related

Android studio Error in building custom font with support lib v26

I am studying to add custom font for different locale.
In Android O, it support font in xml. Also find that we can use the support library to load font in xml backward compatiblity to API >14.
Support library font
I am now using Android Studio 3.0 Beta2 and add the font folder under the res directory.
But building the project, it shows error for the notosanscjktc_medium.otf is not allowed to declared in this.
The android documentation seems not clearly enough for the support library case where to put the font file. Does anyone know where to put the custom font file?
Updated:
Thank you to Junaid Hafeez giving me some hint.
My project is created in Android Studio 2.3.3. Even though later i open it with Android 3.0 , the gradle file usage is old. Now i updated my gradle to use the same as 3.0 using implementation. It now works.

ERROR :rendering problems The following classes could not be found android.support.v7.internal.widget.ActionBarOverlayLayout

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

How to create a ActionBar in Android 2.2 version?

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

Creating new project with compatability library

I can't understand why am I getting this error:
When another people don't get it and are able to create a new project with inner navigation like that. powered by compatability library:
PS: I have every single package of android SDK Tools installed on my computer, and they're all up to date
It is because the wizard doesn't take the compatibility library into consideration. Set your minimum to 14 and then go and change the manifest after you have created your project and include the compatibility library.

How to make Android GridLayout compatible to older version?

New GridLayout for Android 4 is good. Both in terms of code maintainability and performance.
I wanted help with backward compatibility for GridLayout for older version. Waiting for official compatibile package is taking too long. I know its possible and someone did mention that this could be done by copying the class from version 4 platform source.
Would be really great if anybody could guide me how to do this.
For reference please check this post on Google Plus
https://plus.google.com/105051985738280261832/posts/KbqAxUQTzVf
A better way of doing this is using Android Support Library.
Since resource files are also involved it cannot be included as .jar library.
Update the android SDK and support files.
Add your-android-sdk\extras\android\support\v7\gridlayout project to eclipse.
Make the project as library.
Add this library project to your working project.
To use gridlayout in XML use it like this
<android.support.v7.widget.GridLayout> </android.support.v7.widget.GridLayout>
Hope that was helpful.
Check out this project: https://github.com/dlew/android-gridlayout

Categories

Resources