本文整理汇总了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);
}
});
}
示例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);
}
}
}
示例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);
}
}
示例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");
}
}
示例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");
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}