Android API 7 - AppCompat Theme Custom Font - android

Trying to Add App Support Android 2.0 or API Level 7 Support to my application (Current Support is only for the versions of 3.0 & 4.+). as android suggests, i added AppCompat Lib and changed minSDK to 7.
but the problem is i used following style for the buttons
<style name="buttonText" parent="#android:style/TextAppearance">
<item name="android:textSize">16sp</item>
<item name="android:textColor">#color/linecolor</item>
<item name="android:fontFamily">sans-serif</item> <!-- This one not accepting -->
</style>
fontFamily is not available and says "FontFamily requires API Level 16(Current 7)"
I would like to know what is the alternative way to solve this issue?

You mustnt use android: prefix just use it like
<item name="fontFamily">sans-serif</item>
if you added the support library truely.

Related

Change Xamarin.Android Api Version

I already set all Api versions to Api 23 in the Android project properties, but it doesn't seems to help. This is the errorcode I always get:
Could not find android.jar for API Level 25. This means the Android
SDK platform for API Level 25 is not installed. Either install it in
the Android SDK Manager (Tools > Open Android SDK Manager...), or
change your Xamarin.Android project to target an API version that is
installed. (C:\Program Files
(x86)\Android\android-sdk\platforms\android-25\android.jar missing.)
I already tried to switch to Api Version 25 but I don't get an update for Xamarin.Forms and therefore I can't update the other packages.
Edit:
If I update the SDK to Level 25 and try to deploy I receive the following Errors:
The error occurs in the file style.xml:
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="MainTheme" parent="MainTheme.Base">
</style>
<!--Base theme applied no matter what API-->
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!--Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette
colorPrimary is used for the default action bar background-->
<item name="colorPrimary">#2196F3</item>
<!--colorPrimaryDark is used for the status bar-->
<item name="colorPrimaryDark">#1976D2</item>
<!--colorAccent is used as the default value for colorControlActivated
which is used to tint widgets-->
<item name="colorAccent">#FF4081</item>
<!--You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal.-->
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">#style/AppCompatDialogStyle</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#FF4081</item>
</style>
</resources>
If you already changed the API Version, try to install the Nougat 7.1 SDK (Api Level 25). If that is already done, clean %USER%\AppData\Local\Xamarin, clean your solution and install what you need.

Eclipse Android 2.2 project error but Android 4.0 no error

When I create new project for lower android 2.2 label API8 in eclipse there are some error and i can't fixed them. appcompat_v7 inside some problem no found values-v17 - values-v21 and there are also some error my project folder.
After creating ... ...
But when I create project for higher android 4.0 label API(14) there are no error.
After creating ... ...
There are any way to solve this problems.
In 4.0 they use android: prefix for styles but in 2.2 they does not recognise
In 4.0
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CodeFont" parent="#android:style/TextAppearance.Medium">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#00FF00</item>
<item name="android:typeface">monospace</item>
</style>
</resources>
in 2.2
<style name="WindowTitle">
<item name="singleLine">true</item>
<item name="textAppearance">#style/TextAppearance.WindowTitle</item>
<item name="shadowColor">#BB000000</item>
<item name="shadowRadius">2.75</item>
</style>
like wise things changed. So refer the android developer.android.com
Or you can use separate stylesheet from 2.2 . And also without seen the style.xml we cant say that this is the exact problem.
You need to modify your style.xml to ensure API's are supported. Please check this SO post Android AppCompat requires API level 11
This should help you solve the problem you face.

Android material design in Eclipse

Is there any way to create an app with Material design in Eclipse? Hamburger to arrow animation, full screen height navigation drawer...
Yes you can create an app with material design using eclipse.
Please follow each steps below carefully without any error.
Steps:
Create a new Android Project with Target SDK version 21. If your project already exists then just change the Target SDK version.
Add Appcompat v7 lib to your workspace and add this lib to build path of your project. You can find this lib at sdk\extras\android\support\v7.
Set Project build target to version 21.
There should be only 2 values folder in res folder.
values
values-v21
values/styles.xml should be as below.
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
....
// Your style here
</style>
values-v21/style.xml should be as below.
<style name="AppBaseTheme" parent="#android:style/Theme.Material.Light.DarkActionBar">
....
// Your style here
</style>
You can find different style attributes here https://developer.android.com/training/material/theme.html
After following above steps, your app will be ready with material design theme.
Now your second question regarding navigation drawer you can use following link for simple and step by step implementation.
Part 1 http://www.android4devs.com/2014/12/how-to-make-material-design-navigation-drawer.html4
Part 2 http://www.android4devs.com/2015/01/recycler-view-handling-onitemtouch-for.html
This implementation uses recycler view. For that you need to add recycler view lib (location - sdk\extras\android\support\v7) to your project and add it to build path.
You can develop apps with Material Design in Eclipse by using the libraries provided by google. You need to follow the below steps to do that.
Properties> Android> Add...>appcompat_v7
Add...> Android Design Support Library(You can import it from android-sdk\extras\android\support\)
Add...> RecycleViewLibrary & CardViewLibrary libraries for RecycleView and cardView, better material look and feel. (You can import it from android-sdk\extras\android\support\v7\)
Add/Edit values\styles.xml
<style name="MyMaterialTheme.Base" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
Change theme in AndroidManifest.xml file. android:theme="#style/MyMaterialTheme"
extend your Activity by AppCompatActivity.
Hope you can develop Material Designed apps in Eclipse throgh these steps.
Important: Support for the Android Developer Tools (ADT) in Eclipse is ending. You should migrate your app development projects to Android Studio as soon as possible.

AppCompat - Error while styling the actionbar

Im using the appcompat library to implement an action bar. While using a custom style it gives an error android:actionBarStyle requires API level 11 (current min is 10). I want the app to be compatible with android 2.3. Im using the google sample code.
themes.xml
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#drawable/actionbar_background</item>
<!-- Support library compatibility -->
<item name="background">#drawable/actionbar_background</item>
</style>
AppCompat is compatible with 2.3, but you need to define 2 styles (as you have above): 1 for the native actionbar implementation (android:actionBarStyle) and one for the compatibility implementation (actionBarStyle).
If you define both those styles in your values/styles.xml, you will get compile errors - because values/styles.xml is compiled for all api versions, and 2.3 doesn't know about android:actionBarStyle.
So you can duplicate your styles.
Have a values/styles.xml and a values-v14/styles.xml
The styles in values-v14/styles.xml will override any styles in values/styles.xml when run on a api 14 and above device.
Or you can keep all your styles in the one values/styles.xml, but on the attributes you are getting the error on, add a tools:targetApi="14" to the tag, which tells the compiler to ignore this on non api 14 devices.
e.g.
<item name="android:actionBarStyle" tools:targetApi="14">#style/MyActionBar</item>

Inherit from #android:style/Theme.Holo.Light in a minSdkVersion="4" application

I currently have an Android application targeting version 11 of the SDK with a minimum version of 4. I would like to apply the Light version of the Holo theme if the app is running on Honeycomb. Following the instructions here I have tried adding the following to res/values-v11/themes.xml but my application will not compile because #android:style/Theme.Holo.Light does not exist in SDK 4
<resources>
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
</style>
</resources>
Is is possible to get a reference to that theme without having to build separate 1.6-2.x and 3.x versions of my application?
As EboMike pointed out in the comments this was a problem with setting the build target to the Minimum SDK version instead of the Target SDK version.

Categories

Resources