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