Android-studio-material-template icon indicating copy to clipboard operation
Android-studio-material-template copied to clipboard

support froyo ?

Open JoachimR opened this issue 9 years ago • 2 comments

Is it possible to support Android 2.2 (level 8)?

drawer_row.xml uses

android:background="?android:attr/selectableItemBackground"  

which requires level 11 rather than 8

JoachimR avatar May 05 '15 10:05 JoachimR

If that's the only thing that requires 11 you can simple remove it. That's used for ripple effect on latter android versions.

kanytu avatar May 05 '15 19:05 kanytu

yeah ok, the NavigationDrawerAdapter needs the to be updated as follows:

public ViewHolder(View itemView) {
            super(itemView);
            textView = (TextView) itemView.findViewById(R.id.item_name);

            if (Build.VERSION.SDK_INT >= 11) {
                textView.setBackgroundDrawable(Utils.getDrawableFromAttr(context,
                        R.attr.selectableItemBackground));
            }

        }

    /**
     *
     * @param context
     * @param resId the R.attr id
     * @return
     */
    public static Drawable getDrawableFromAttr(Context context, int resId) {
        int[] attrs = new int[]{resId};
        TypedArray ta = context.getTheme().obtainStyledAttributes(attrs);
        Drawable drawableFromTheme = ta.getDrawable(0);
        ta.recycle();
        return drawableFromTheme;
    }

JoachimR avatar May 06 '15 13:05 JoachimR