當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。