当前位置: 首页>>代码示例>>Java>>正文


Java VectorDrawableCompat.create方法代码示例

本文整理汇总了Java中android.support.graphics.drawable.VectorDrawableCompat.create方法的典型用法代码示例。如果您正苦于以下问题:Java VectorDrawableCompat.create方法的具体用法?Java VectorDrawableCompat.create怎么用?Java VectorDrawableCompat.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.graphics.drawable.VectorDrawableCompat的用法示例。


在下文中一共展示了VectorDrawableCompat.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onSharedElementEnter

import android.support.graphics.drawable.VectorDrawableCompat; //导入方法依赖的package包/类
@Override
public void onSharedElementEnter() {
    final View view = itemView.findViewById(R.id.image);

    Resources res = itemView.getContext().getResources();
    final Drawable playOverlay = VectorDrawableCompat.create(res,
            R.drawable.play_indicator, itemView.getContext().getTheme());

    if (playOverlay == null) {
        return;
    }

    view.post(new Runnable() {
        @Override
        public void run() {
            int dimen = (int) view.getContext().getResources()
                    .getDimension(R.dimen.twenty_four_dp) * 2;

            int left = view.getWidth() / 2 - dimen / 2;
            int top = view.getHeight() / 2 - dimen / 2;

            playOverlay.setBounds(left, top, left + dimen, top + dimen);
            view.getOverlay().add(playOverlay);
        }
    });
}
 
开发者ID:kollerlukas,项目名称:Camera-Roll-Android-App,代码行数:27,代码来源:VideoViewHolder.java

示例2: getDrawable

import android.support.graphics.drawable.VectorDrawableCompat; //导入方法依赖的package包/类
static Drawable getDrawable(Context context, int drawableResId) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        return context.getDrawable(drawableResId);
    } else {
        try {
            return VectorDrawableCompat.create(context.getResources(), drawableResId, null);
        }catch (Resources.NotFoundException e){
            return ContextCompat.getDrawable(context, drawableResId);
        }
    }
}
 
开发者ID:simplezhli,项目名称:ChangeTabLayout,代码行数:12,代码来源:DrawableUtils.java

示例3: onCreate

import android.support.graphics.drawable.VectorDrawableCompat; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_changas_activas);
    // Setting ViewPager for each Tabs
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager_ca);
    final Integer idCategoria = getIntent().getIntExtra("EXTRA_POSITION",0);
    setupViewPager(viewPager,idCategoria);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerCA);
    // Adding menu icon to Toolbar
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar_ca));
    if (getSupportActionBar() != null) {
        VectorDrawableCompat indicator
                = VectorDrawableCompat.create(getResources(), R.drawable.ic_menu, getTheme());
        indicator.setTint(ResourcesCompat.getColor(getResources(),R.color.white,getTheme()));
        //getSupportActionBar().setHomeAsUpIndicator(indicator);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        Resources resources = getResources();
        String categoryName = ((resources.getStringArray(R.array.array_categories))[idCategoria].toString());
        getSupportActionBar().setTitle("Categoria: "+categoryName);
    }

}
 
开发者ID:sloiza,项目名称:changApp,代码行数:24,代码来源:ChangasPorCategoriaActivity.java

示例4: onCreate

import android.support.graphics.drawable.VectorDrawableCompat; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_changas_pendientes);
    // Setting ViewPager for each Tabs
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager_cp);
    setupViewPager(viewPager);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerCP);
    // Adding menu icon to Toolbar
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar_cp));
    if (getSupportActionBar() != null) {
        VectorDrawableCompat indicator
                = VectorDrawableCompat.create(getResources(), R.drawable.ic_menu, getTheme());
        indicator.setTint(ResourcesCompat.getColor(getResources(),R.color.white,getTheme()));
        //getSupportActionBar().setHomeAsUpIndicator(indicator);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("Mis changas pendientes");
    }

}
 
开发者ID:sloiza,项目名称:changApp,代码行数:21,代码来源:ChangasPendientesActivity.java

示例5: onCreate

import android.support.graphics.drawable.VectorDrawableCompat; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_changas_activas);
    // Setting ViewPager for each Tabs
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager_ca);
    setupViewPager(viewPager);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerCA);
    // Adding menu icon to Toolbar
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar_ca));
    if (getSupportActionBar() != null) {
        VectorDrawableCompat indicator
                = VectorDrawableCompat.create(getResources(), R.drawable.ic_menu, getTheme());
        indicator.setTint(ResourcesCompat.getColor(getResources(),R.color.white,getTheme()));
        //getSupportActionBar().setHomeAsUpIndicator(indicator);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("Mis changas");
    }

}
 
开发者ID:sloiza,项目名称:changApp,代码行数:21,代码来源:ChangasActivasActivity.java

示例6: setFavouriteIcon

import android.support.graphics.drawable.VectorDrawableCompat; //导入方法依赖的package包/类
void setFavouriteIcon(boolean isFavourite)
{

    if(fab==null)
    {
        return;
    }

    if(isFavourite)
    {
        Drawable drawable = VectorDrawableCompat.create(getResources(), R.drawable.ic_favorite_white_24px, getTheme());
        fab.setImageDrawable(drawable);
    }
    else
    {
        Drawable drawable2 = VectorDrawableCompat.create(getResources(), R.drawable.ic_favorite_border_white_24px, getTheme());
        fab.setImageDrawable(drawable2);
    }
}
 
开发者ID:SumeetMoray,项目名称:Nearby-Shops-End-User-Android-app,代码行数:20,代码来源:ShopDetail.java

示例7: getVectorDrawable

import android.support.graphics.drawable.VectorDrawableCompat; //导入方法依赖的package包/类
public static Drawable getVectorDrawable(Context context, int resId) {
    VectorDrawableCompat drawable;
    try {
        drawable = VectorDrawableCompat.create(context.getResources(), resId, context.getTheme());
    } catch (Exception e) {
        e.printStackTrace();
        return new ColorDrawable(Color.TRANSPARENT);
    }

    if (drawable != null) {
        Drawable icon = DrawableCompat.wrap(drawable.getCurrent());
        DrawableCompat.setTint(icon, Color.WHITE);
        return icon;
    } else {
        Log.wtf(context.getClass().getName(), "Can't get a vector drawable.");
        return new ColorDrawable(Color.TRANSPARENT);
    }
}
 
开发者ID:TheAndroidMaster,项目名称:Bagels,代码行数:19,代码来源:ImageUtils.java

示例8: getBitmap

import android.support.graphics.drawable.VectorDrawableCompat; //导入方法依赖的package包/类
private Bitmap getBitmap(int resource) {
    VectorDrawableCompat drawable = VectorDrawableCompat.create(mContext.getResources(), resource, null);
    if (drawable != null) {
        Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
        drawable.draw(canvas);
        return bitmap;
    } else {
        return null;
    }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:13,代码来源:ImageHelper.java

示例9: vectorToBitmap

import android.support.graphics.drawable.VectorDrawableCompat; //导入方法依赖的package包/类
public static Bitmap vectorToBitmap(Context ctx, @DrawableRes int resVector) {
    Drawable drawable =VectorDrawableCompat.create(ctx.getResources(),resVector,null);
    //Drawable drawable = AppCompatDrawableManager.get().getDrawable(ctx, resVector);
    Bitmap b = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(b);
    drawable.setBounds(0, 0, c.getWidth(), c.getHeight());
    drawable.draw(c);
    return b;
}
 
开发者ID:z-chu,项目名称:FriendBook,代码行数:10,代码来源:BitmapUtil.java

示例10: getDrawable

import android.support.graphics.drawable.VectorDrawableCompat; //导入方法依赖的package包/类
public static Drawable getDrawable(Context context, int drawableResId) {
    Drawable drawable;

    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
        drawable = context.getResources().getDrawable(drawableResId, context.getTheme());
    } else {
        drawable = VectorDrawableCompat.create(context.getResources(), drawableResId, context.getTheme());
    }

    return drawable;
}
 
开发者ID:open-android,项目名称:Timeline,代码行数:12,代码来源:VectorDrawableUtils.java

示例11: getBitmapFromVectorDrawable

import android.support.graphics.drawable.VectorDrawableCompat; //导入方法依赖的package包/类
public static Bitmap getBitmapFromVectorDrawable(Context context, @DrawableRes int drawableResId) {


        Drawable drawable = VectorDrawableCompat.create(context.getResources(), drawableResId, null);
        DisplayMetrics metrics = context.getResources().getDisplayMetrics();
        Bitmap bitmap = BitmapUtil.toBitmap(drawable, metrics, 48f, 0);
        return bitmap;
    }
 
开发者ID:cahergil,项目名称:Farmacias,代码行数:9,代码来源:Utils.java

示例12: getVectorBitmap

import android.support.graphics.drawable.VectorDrawableCompat; //导入方法依赖的package包/类
public static Bitmap getVectorBitmap(Context context, @DrawableRes int id) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
        try {
            return drawableToBitmap(ContextCompat.getDrawable(context, id));
        } catch (Resources.NotFoundException e) {
            return drawableToBitmap(null);
        }
    }

    Drawable drawable;
    try {
        drawable = VectorDrawableCompat.create(context.getResources(), id, context.getTheme());
    } catch (Resources.NotFoundException e1) {
        try {
            drawable = ContextCompat.getDrawable(context, id);
        } catch (Resources.NotFoundException e2) {
            return drawableToBitmap(null);
        }
    }

    if (drawable != null) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
            drawable = (DrawableCompat.wrap(drawable)).mutate();

        Bitmap result = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(result);
        drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
        drawable.draw(canvas);
        return result;
    }

    return null;
}
 
开发者ID:TheAndroidMaster,项目名称:MediaNotification,代码行数:34,代码来源:ImageUtils.java

示例13: getVector2Bitmap

import android.support.graphics.drawable.VectorDrawableCompat; //导入方法依赖的package包/类
public static Bitmap getVector2Bitmap(Context context, int id) {
    VectorDrawableCompat vectorDrawable = VectorDrawableCompat.create(context.getResources(), id, context.getTheme());
    Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(),
            vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    vectorDrawable.draw(canvas);
    return bitmap;
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:10,代码来源:Utils.java

示例14: updateMuteButton

import android.support.graphics.drawable.VectorDrawableCompat; //导入方法依赖的package包/类
private boolean updateMuteButton(@ColorRes int colorRes, @DrawableRes int iconRes) {
        int color = ResourcesCompat.getColor(getResources(), colorRes, getActivity().getTheme());
        Drawable normalDrawable = VectorDrawableCompat.create(getResources(), iconRes, getActivity().getTheme());

        if (normalDrawable != null) {
            Drawable wrapDrawable = DrawableCompat.wrap(normalDrawable);
            DrawableCompat.setTint(wrapDrawable, color);

//                                    DrawableCompat.setTint(normalDrawable, color);
            muteButton.setImageDrawable(normalDrawable);
            return true;
        }

        return false;
    }
 
开发者ID:MimiReader,项目名称:mimi-reader,代码行数:16,代码来源:GalleryWebmFragment.java

示例15: onDraw

import android.support.graphics.drawable.VectorDrawableCompat; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    mRect.right = getWidth();



    canvas.drawRect(mRect,mRectPaint);
    Log.d("No of tabs=",""+noOfTabs);
    Log.d("X-axis value=",""+(2/(float)noOfTabs));
    Log.d("midptx value=",""+midpt.x);

    midpt.y = 180;

    leftpt.x=midpt.x-40;
    leftpt.y=140;

    rightpt.x=midpt.x+40;
    rightpt.y=140;

    triangle.moveTo(leftpt.x, leftpt.y); // Top
    triangle.lineTo(midpt.x, midpt.y); // Bottom left
    triangle.lineTo(rightpt.x ,rightpt.y); // Bottom right
    triangle.lineTo(leftpt.x, leftpt.y); // Back to Top
    triangle.close();

    canvas.drawPath(triangle,mRectPaint);

    for(int i =0; i<resources.length; i++)
    {
        vds[i] = VectorDrawableCompat.create(getContext().getResources(), resources[i], null);
    }

    for(int i=0; i<resources.length; i++)
    {
        //imgRes[i] = BitmapFactory.decodeResource(getResources(),resources[i]); //Use for png images
        imgRes[i] = getBitmap(vds[i]);

    }
  //  canvas.drawBitmap(imgRes[0],);
    canvas.drawBitmap(imgRes[0],(getWidth()/noOfTabs)/2-(imgRes[0].getWidth()/2),70-(imgRes[0].getHeight())/2,null);
    for(int i =1; i<noOfTabs; i++) {
        canvas.drawBitmap(imgRes[i],(i / (float) noOfTabs) * getWidth()+(getWidth()/noOfTabs)/2-(imgRes[i].getWidth()/2),70-(imgRes[i].getHeight())/2,null);
    }
}
 
开发者ID:Jhuku,项目名称:TriangularCustomView,代码行数:46,代码来源:IndicatorView.java


注:本文中的android.support.graphics.drawable.VectorDrawableCompat.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。