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


Java VectorDrawableCompat类代码示例

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


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

示例1: initAttributeSet

import android.support.graphics.drawable.VectorDrawableCompat; //导入依赖的package包/类
private void initAttributeSet(Context context, AttributeSet attrs) {
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MineRowView);
    int iconResId = typedArray.getResourceId(R.styleable.MineRowView_mine_icon, 0);
    if (iconResId != 0) {
        Drawable icon = VectorDrawableCompat.create(typedArray.getResources(),iconResId, null);
        ivIcon.setImageDrawable(icon);
    }

    String title = typedArray.getString(R.styleable.MineRowView_mine_title);
    tvTitle.setText(title);
    boolean dividerVisibility = typedArray.getBoolean(R.styleable.MineRowView_mine_divider_visibility, true);
    divider.setVisibility(dividerVisibility ? View.VISIBLE : View.GONE);
    boolean arrowVisibility = typedArray.getBoolean(R.styleable.MineRowView_mine_arrow_visibility, true);
    arrow.setVisibility(arrowVisibility ? View.VISIBLE : View.GONE);
    typedArray.recycle();


}
 
开发者ID:z-chu,项目名称:FriendBook,代码行数:19,代码来源:MineRowView.java

示例2: drawableToBitmap

import android.support.graphics.drawable.VectorDrawableCompat; //导入依赖的package包/类
public Bitmap drawableToBitmap(Drawable drawable) {
    Bitmap bitmap = null;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && (drawable instanceof VectorDrawable || drawable instanceof VectorDrawableCompat)) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            drawable = (DrawableCompat.wrap(drawable)).mutate();
        }

        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);
    } else if (drawable instanceof BitmapDrawable) {
        bitmap = ((BitmapDrawable) drawable).getBitmap();
    }
    return bitmap;
}
 
开发者ID:gsantner,项目名称:markor,代码行数:18,代码来源:ContextUtils.java

示例3: getBitmapFromDrawable

import android.support.graphics.drawable.VectorDrawableCompat; //导入依赖的package包/类
public Bitmap getBitmapFromDrawable(int drawableId) {
    Bitmap bitmap = null;
    Drawable drawable = ContextCompat.getDrawable(_context, drawableId);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && (drawable instanceof VectorDrawable || drawable instanceof VectorDrawableCompat)) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            drawable = (DrawableCompat.wrap(drawable)).mutate();
        }

        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);
    } else if (drawable instanceof BitmapDrawable) {
        bitmap = ((BitmapDrawable) drawable).getBitmap();
    }
    return bitmap;
}
 
开发者ID:gsantner,项目名称:markor,代码行数:19,代码来源:ContextUtils.java

示例4: 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

示例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);
    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

示例6: onCreate

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

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

示例7: 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

示例8: 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

示例9: onCreate

import android.support.graphics.drawable.VectorDrawableCompat; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_changas_finalizadas);
    // Setting ViewPager for each Tabs
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager_cf);
    setupViewPager(viewPager);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerCF);
    // Adding menu icon to Toolbar
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar_cf));
    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 finalizadas");
    }

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

示例10: getBitmapFromDrawable

import android.support.graphics.drawable.VectorDrawableCompat; //导入依赖的package包/类
/**
 * Получение объекта Bitmap из Drawable из ресурсов
 */
public static Bitmap getBitmapFromDrawable(Context context, @DrawableRes int drawableId) {
    Drawable drawable = ContextCompat.getDrawable(context, drawableId);

    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    } else if (drawable instanceof VectorDrawable || drawable instanceof VectorDrawableCompat) {
        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 {
        throw new IllegalArgumentException("unsupported drawable type");
    }
}
 
开发者ID:interactiveservices,项目名称:utils-android,代码行数:22,代码来源:BitmapUtils.java

示例11: setRadioButtonDrawable

import android.support.graphics.drawable.VectorDrawableCompat; //导入依赖的package包/类
private static void setRadioButtonDrawable(Context context, RadioButton button,
                                           @DrawableRes int id) {
    ColorStateList list = new ColorStateList(new int[][] {
            new int[] { -android.R.attr.state_checked },
            new int[] { android.R.attr.state_checked }
    }, new int[] {
            ThemeUtils.getColor(context, R.attr.compose_image_button_tint),
            ThemeUtils.getColor(context, R.attr.colorAccent)
    });
    Drawable drawable = VectorDrawableCompat.create(context.getResources(), id,
            context.getTheme());
    if (drawable == null) {
        return;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        button.setButtonTintList(list);
    } else {
        drawable = DrawableCompat.wrap(drawable);
        DrawableCompat.setTintList(drawable, list);
    }
    button.setButtonDrawable(drawable);
}
 
开发者ID:Vavassor,项目名称:Tusky,代码行数:23,代码来源:ComposeOptionsFragment.java

示例12: 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

示例13: onCreate

import android.support.graphics.drawable.VectorDrawableCompat; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_cart);
    viewModel = ViewModelProviders.of(this).get(CartViewModel.class);

    fab = (FloatingActionButton) findViewById(R.id.fab);
    toolbar = (Toolbar) findViewById(R.id.toolbar);

    setupToolbar();
    handleDeepLink();

    fab.setImageDrawable(VectorDrawableCompat.create(getResources(), R.drawable.ic_share_white_24dp, null));
    fab.setOnClickListener(view -> {
        String cartId = viewModel.getCartId().getValue();
        ShareCompat.IntentBuilder.from(this)
                .setText(String.format(Locale.US, "Check out my shopping cart now using Android Instant Apps! \n%s/cart/%s", ROOT_ENDPOINT, cartId))
                .setType("text/plain")
                .setChooserTitle(share_cart)
                .startChooser();
    });
}
 
开发者ID:willowtreeapps,项目名称:android-instant-apps-demo,代码行数:23,代码来源:CartActivity.java

示例14: onCreate

import android.support.graphics.drawable.VectorDrawableCompat; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_item_detail);
    viewModel = ViewModelProviders.of(this).get(ItemDetailViewModel.class);
    viewModel.getCartId().observe(this, this::updatedCartId);

    fab = (FloatingActionButton) findViewById(R.id.fab);
    toolbar = (Toolbar) findViewById(R.id.toolbar);

    handleDeepLink();
    setupToolbar();

    fab.setImageDrawable(VectorDrawableCompat.create(getResources(), R.drawable.ic_add_shopping_cart_white_24dp, null));
    fab.setOnClickListener(this::addToCart);
}
 
开发者ID:willowtreeapps,项目名称:android-instant-apps-demo,代码行数:17,代码来源:ItemDetailActivity.java

示例15: drawableToBitmap

import android.support.graphics.drawable.VectorDrawableCompat; //导入依赖的package包/类
public static Bitmap drawableToBitmap(Drawable drawable) {
    if (drawable == null) drawable = new ColorDrawable(Color.TRANSPARENT);
    if (drawable instanceof BitmapDrawable) return ((BitmapDrawable) drawable).getBitmap();
    if (drawable instanceof VectorDrawableCompat)
        return Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);

    int width = drawable.getIntrinsicWidth();
    width = width > 0 ? width : 1;
    int height = drawable.getIntrinsicHeight();
    height = height > 0 ? height : 1;

    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);

    return bitmap;
}
 
开发者ID:TheAndroidMaster,项目名称:Rocket,代码行数:19,代码来源:ImageUtils.java


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