问题
there are many questions regarding this but not even single helped me.
So please tell me how to enable material design features in eclipse.
i have also imported appcompat_v7 library in project but it does not create a folder with name values_v21 which helps in using those feature i think.
So please help me out in this
here is my styles.xml file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/AppTheme_ActionBar</item>
<item name="android:actionBarSize">@dimen/action_bar_height</item>
<item name="android:windowContentOverlay">@drawable/actionbar_shadow</item>
<item name="android:homeAsUpIndicator">@drawable/ic_ab_up_compat</item>
<item name="android:actionBarTabTextStyle">@style/tabtextcolor</item>
<item name="android:actionOverflowButtonStyle">@style/AppTheme_ActionBar_Overflow</item>
</style>
<style name="AppTheme_ActionBar" parent="android:Widget.Holo.ActionBar.Solid">
<item name="android:background">@color/apptheme_primary</item>
<item name="android:actionBarTabTextStyle">@style/tabtextcolor</item>
<item name="android:icon">@drawable/actionbar_icon_placeholder_compat</item>
<item name="android:titleTextStyle">@style/AppTheme_ActionBar_Title</item>
</style>
<style name="AppTheme_ActionBar_Title" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@android:color/white</item>
<item name="android:textSize">20sp</item>
</style>
<style name="AppTheme_ActionBar_Overflow" parent="android:Widget.ActionButton.Overflow">
<item name="android:src">@drawable/ic_ab_overflow_compat</item>
</style>
<style name="tabtextcolor" parent="@android:style/Widget.Holo.Light.ActionBar.TabText">
<item name="android:textColor">@android:color/white</item>
</style>
</resources>
回答1:
There are some points you should check:
- Import into eclipse, last version of
android-support-v7-appcompatproject. You should update via SDK Manager, and import project from{your_path_to_android_sdk}/extras/android/support/v7/appcompat - Add this project as library dependency to your project
In
styles.xmluseTheme.AppCompat.LightorTheme.AppCompat:style name="AppTheme" parent="@style/Theme.AppCompat.Light"
回答2:
A simple guideline:
- import the appcompat-v7 project and add it as a library dependency for your project
- let your theme inherit some of the appcompat themes. For example
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light"> - Note that not all widgets (ui elements) are material-styled by appcompat
- Follow the examples and explanations in the android-developers blogspot.
- The
values-vXYfolders are used to add specific resources for a specific platform. For example you might add a style (in avalues-v21folder) that inherits some of the material styles that are built-in and available only one api level 21+. These folders are created manually and are only used if you want an alternative resource for a specific platform level. They are used when you want your app to fit better in all/many android versions. More info - at the android developers portal
来源:https://stackoverflow.com/questions/28980962/how-to-use-material-design-features-in-api-lower-than-21-in-eclipse