當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageView.setImageTintList方法代碼示例

本文整理匯總了Java中android.widget.ImageView.setImageTintList方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageView.setImageTintList方法的具體用法?Java ImageView.setImageTintList怎麽用?Java ImageView.setImageTintList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.ImageView的用法示例。


在下文中一共展示了ImageView.setImageTintList方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setBottomIconOriColor

import android.widget.ImageView; //導入方法依賴的package包/類
private void setBottomIconOriColor(BottomNavigationView bottomView) {
    try {
        Field mMenuViewField = BottomNavigationView.class.getDeclaredField("mMenuView");
        mMenuViewField.setAccessible(true);
        BottomNavigationMenuView mMenuView = (BottomNavigationMenuView) mMenuViewField.get(bottomView);

        Field mButtonsField = BottomNavigationMenuView.class.getDeclaredField("mButtons");
        mButtonsField.setAccessible(true);
        BottomNavigationItemView[] mButtons = (BottomNavigationItemView[]) mButtonsField.get(mMenuView);

        Field mIconField = BottomNavigationItemView.class.getDeclaredField("mIcon");
        mIconField.setAccessible(true);

        for (BottomNavigationItemView item : mButtons) {
            ImageView mIcon = (ImageView) mIconField.get(item);
            mIcon.setImageTintList(null);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:iAcn,項目名稱:MBEStyle,代碼行數:23,代碼來源:MainActivity.java

示例2: show

import android.widget.ImageView; //導入方法依賴的package包/類
public static void show(Context context, CharSequence charSequence, int type) {
    View layout;
    if (toast == null) {
        toast = Toast.makeText(context, "", Toast.LENGTH_SHORT);
        initToast(toast);
        layout = LayoutInflater.from(context).inflate(R.layout.base_toast, null);
        ((TextView) layout.findViewById(R.id.base_toast_text_view)).setText(charSequence);
        toast.setView(layout);
        toast.setGravity(Gravity.TOP, 0, 0);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            toast.getView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        }
    } else {
        layout = toast.getView();
    }

    TextView titleView = find(layout, R.id.base_toast_text_view);
    ImageView imageView = find(layout, R.id.base_toast_image_view);

    if (titleView != null) {
        titleView.setText(charSequence);
    }
    if (imageView != null) {
        if (type == TYPE_NONE) {
            imageView.setVisibility(View.GONE);
        } else {
            imageView.setVisibility(View.VISIBLE);
            switch (type % 4) {
                case TYPE_OK:
                    imageView.setImageResource(R.drawable.base_ok);
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        imageView.setImageTintList(ColorStateList.valueOf(SkinHelper.getSkin().getThemeSubColor()));
                    }
                    break;
                case TYPE_INFO:
                    imageView.setImageResource(R.drawable.base_info);
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        imageView.setImageTintList(ColorStateList.valueOf(SkinHelper.getSkin().getThemeSubColor()));
                    }
                    break;
                case TYPE_ERROR:
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        imageView.setImageTintList(ColorStateList.valueOf(Color.parseColor("#d62119")));
                    }
                    imageView.setImageResource(R.drawable.base_failed_red);
                    break;
            }
        }
    }
    toast.show();
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:52,代碼來源:T2.java


注:本文中的android.widget.ImageView.setImageTintList方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。