how to use material design features in api lower than 21 in eclipse?

大城市里の小女人 提交于 2019-12-18 05:13:33

问题


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-appcompat project. 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.xml use Theme.AppCompat.Light or Theme.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-vXY folders are used to add specific resources for a specific platform. For example you might add a style (in a values-v21 folder) 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!