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


Java ImageView.setColorFilter方法代码示例

本文整理汇总了Java中android.widget.ImageView.setColorFilter方法的典型用法代码示例。如果您正苦于以下问题:Java ImageView.setColorFilter方法的具体用法?Java ImageView.setColorFilter怎么用?Java ImageView.setColorFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.ImageView的用法示例。


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

示例1: invalidateActivated

import android.widget.ImageView; //导入方法依赖的package包/类
private TextView invalidateActivated(View view, final boolean isActive, final boolean noArrowIfAlone, final boolean allowArrowVisible) {
    int contentColor = isActive ? contentColorActivated : contentColorDeactivated;
    LinearLayout child = (LinearLayout) view;
    TextView tv = (TextView) child.getChildAt(0);
    tv.setTextColor(contentColor);
    ImageView iv = (ImageView) child.getChildAt(1);
    iv.setColorFilter(contentColor, PorterDuff.Mode.SRC_IN);
    if (noArrowIfAlone && getChildCount() == 1)
        iv.setVisibility(View.GONE);
    else if (allowArrowVisible)
        iv.setVisibility(View.VISIBLE);
    else
        iv.setVisibility(View.GONE);
    return tv;
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:16,代码来源:BreadCrumbLayout.java

示例2: getView

import android.widget.ImageView; //导入方法依赖的package包/类
@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View itemView = LayoutInflater.from(getContext()).inflate(R.layout.spinner_shape_item, parent, false);
    ImageView imageView = (ImageView) itemView.findViewById(R.id.spinner_image);
    imageView.setImageResource(getItem(position));
    imageView.setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_ATOP);
    return itemView;
}
 
开发者ID:cipherthinkers,项目名称:shapeflyer,代码行数:10,代码来源:ImageArrayAdapter.java

示例3: setStars

import android.widget.ImageView; //导入方法依赖的package包/类
@BindingAdapter({"stars"})
public static void setStars(LinearLayout linearLayout, float rating) {

	Context context = linearLayout.getContext();
	int color = AssetHelper.getColorFromScore(rating);

	// Child 0 is the textView with the written score
	Drawable roundedBackground = ContextCompat.getDrawable(context, R.drawable.rounded_edges);
	roundedBackground.setColorFilter(color, PorterDuff.Mode.ADD);
	linearLayout.getChildAt(0).setBackground(roundedBackground);

	int nStars = Math.round(rating);
	for (int i = 1; i <= nStars; ++i) {
		ImageView imageView = (ImageView) linearLayout.getChildAt(i);
		imageView.setColorFilter(color);
	}
}
 
开发者ID:EduardoVernier,项目名称:bikedeboa-android,代码行数:18,代码来源:BindingAdapters.java

示例4: onVoiceMuteClicked

import android.widget.ImageView; //导入方法依赖的package包/类
public void onVoiceMuteClicked(View view) {
    log.info("onVoiceMuteClicked " + view + " " + mUidsList.size() + " video_status: " + mVideoMuted + " audio_status: " + mAudioMuted);
    if (mUidsList.size() == 0) {
        return;
    }

    RtcEngine rtcEngine = rtcEngine();
    rtcEngine.muteLocalAudioStream(mAudioMuted = !mAudioMuted);

    ImageView iv = (ImageView) view;

    if (mAudioMuted) {
        iv.setColorFilter(getResources().getColor(R.color.agora_blue), PorterDuff.Mode.MULTIPLY);
    } else {
        iv.clearColorFilter();
    }
}
 
开发者ID:huangjingqiang,项目名称:SWDemo,代码行数:18,代码来源:ChatActivity.java

示例5: tintOverflow

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * Sets the color of the overflow menu item within the Toolbar.
 *
 * @param toolbar the toolbar
 * @param color   color to set the overflow icon to
 * @return true if tint was set.
 */
public static boolean tintOverflow(@NonNull Toolbar toolbar, @ColorInt int color) {
    @SuppressLint("PrivateResource") final String overflowDescription = toolbar.getContext().getString(R.string.abc_action_menu_overflow_description);
    final ArrayList<View> outViews = new ArrayList<>();
    toolbar.findViewsWithText(outViews, overflowDescription,
            View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
    if (outViews.isEmpty()) {
        return false;
    }
    ImageView overflow = (ImageView) outViews.get(0);
    overflow.setColorFilter(color);
    return true;
}
 
开发者ID:jumaallan,项目名称:AndelaTrackChallenge,代码行数:20,代码来源:Easel.java

示例6: setupNavigationButton

import android.widget.ImageView; //导入方法依赖的package包/类
private void setupNavigationButton(@NonNull View view, @IdRes int buttonId, @IdRes int imageId) {
    FrameLayout frameButton = view.findViewById(buttonId);
    frameButton.setOnClickListener(this);
    frameButton.setOnLongClickListener(this);
    ImageView buttonImage = view.findViewById(imageId);
    buttonImage.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:8,代码来源:BookmarksFragment.java

示例7: onCreate

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // This is one half of configuring the action bar to have an up (back) arrow instead of
    // the usual hamburger menu. The other half is the override of configureActionBar().
    // I would like to put this line in that method but for some unknown reason that doesn't
    // work...we get no control at all in the hamburger position.
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    filter = getIntent().getStringExtra("filter");

    // Initialize the bookshelf label (empty in MainActivity) with the data
    // passed through our intent.
    View toolbar = findViewById(R.id.toolbar);
    final int background = Color.parseColor("#" + getIntent().getStringExtra("background"));
    toolbar.setBackgroundColor(background);
    TextView labelText = (TextView) findViewById(R.id.shelfName);
    labelText.setText(getIntent().getStringExtra("label"));
    ImageView bloomIcon = (ImageView)findViewById(R.id.bloom_icon);
    // replace the main bloom icon with the bookshelf one.
    bloomIcon.setImageResource(R.drawable.bookshelf);

    // The color chosen for the bookshelf may not contrast well with the default white
    // color of text and the back arrow and the default black color of the bookshelf icon.
    // Change them all to black or white, whichever gives better contrast.
    int forecolor = pickTextColorBasedOnBgColor(background, Color.WHITE, Color.BLACK);
    labelText.setTextColor(forecolor);
    // This bit of magic from https://stackoverflow.com/questions/26788464/how-to-change-color-of-the-back-arrow-in-the-new-material-theme
    // makes the the back arrow use the contrasting foreground color
    Drawable upArrow = ((android.support.v7.widget.Toolbar)toolbar).getNavigationIcon();
    upArrow.setColorFilter(forecolor, PorterDuff.Mode.SRC_ATOP);

    // And this bit, from https://stackoverflow.com/questions/1309629/how-to-change-colors-of-a-drawable-in-android,
    // switches the color of the bookshelf icon.
    bloomIcon.setColorFilter(forecolor);
}
 
开发者ID:BloomBooks,项目名称:BloomReader,代码行数:37,代码来源:ShelfActivity.java

示例8: onLocalAudioMuteClicked

import android.widget.ImageView; //导入方法依赖的package包/类
public void onLocalAudioMuteClicked(View view) {
    ImageView iv = (ImageView) view;
    if (iv.isSelected()) {
        iv.setSelected(false);
        iv.clearColorFilter();
    } else {
        iv.setSelected(true);
        iv.setColorFilter(getResources().getColor(R.color.colorPrimary), PorterDuff.Mode.MULTIPLY);
    }

    mRtcEngine.muteLocalAudioStream(iv.isSelected());
}
 
开发者ID:AgoraIO,项目名称:Agora-Video-Source-Android,代码行数:13,代码来源:VideoChatViewActivity.java

示例9: Holder

import android.widget.ImageView; //导入方法依赖的package包/类
Holder(View itemView) {
    super(itemView);
    this.tag = (TextView) itemView.findViewById(R.id.log_tag);
    this.datetime = (TextView) itemView.findViewById(R.id.log_datetime);
    this.body = (TextView) itemView.findViewById(R.id.log_body);

    this.buttonShare = itemView.findViewById(R.id.log_button_share);

    this.bodyRoot = itemView.findViewById(R.id.log_body_root);
    this.buttonExpand = itemView.findViewById(R.id.log_button_expand);

    Context context = itemView.getContext();

    ImageView icon = (ImageView) itemView.findViewById(R.id.log_icon);
    icon.getBackground().setColorFilter(CurrentTheme.getColorPrimary(context), PorterDuff.Mode.MULTIPLY);
    icon.setColorFilter(CurrentTheme.getIconColorOnColoredBackgroundCode(context));
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:18,代码来源:LogsAdapter.java

示例10: styleVideoAsViewed

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * Show the video as Viewed. We display a semi-transparent grey overlay over the video
 * thumbnail.
 */
private void styleVideoAsViewed(View videoItemView) {
    ImageView thumbnailView = (ImageView) videoItemView.findViewById(R.id.thumbnail);
    thumbnailView.setColorFilter(getContext().getResources().getColor(
            R.color.video_scrim_watched));
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:10,代码来源:VideoLibraryFilteredFragment.java

示例11: onCreate

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    this.context = this;

    appPreferences = App.getAppPreferences();
    packageManager = getPackageManager();

    setInitialConfiguration();
    OtherUtils.requestPermissions(context);

    recyclerView = (RecyclerView) findViewById(R.id.app_list);
    refresh = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh);
    noResults = (LinearLayout) findViewById(R.id.no_results);

    icon = (ImageView) findViewById(R.id.no_results_icon);
    if (appPreferences.getTheme().equals("0")) {
        icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.grey_two));
    }

    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(linearLayoutManager);
    drawer = setNavigationDrawer(context, toolbar, recyclerView, false, appInstalledAdapter, appSystemAdapter, appDisabledAdapter, appHiddenAdapter, appFavoriteAdapter);

    // might be useful in the future
    if (!appPreferences.getInitialSetup()) {
        appPreferences.setInitialSetup(true);
    }

    refresh.setColorSchemeColors(appPreferences.getPrimaryColor());
    refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            refresh.setRefreshing(true);
            new getInstalledApps().execute();
        }
    });

    refresh.post(new Runnable() {
        @Override
        public void run() {
            refresh.setRefreshing(true);
        }
    });
    new getInstalledApps().execute();
}
 
开发者ID:dkanada,项目名称:OpenAPK,代码行数:50,代码来源:MainActivity.java

示例12: setLoadingDrawable

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
public void setLoadingDrawable(ImageView imageView, Drawable drawable) {
    imageView.setImageDrawable(drawable);
    imageView.setColorFilter(mLoadingColorFilter);
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:6,代码来源:VideoThumbProcessor.java

示例13: setImageViewTint

import android.widget.ImageView; //导入方法依赖的package包/类
public static void setImageViewTint(ImageView view, @AttrRes int attribute) {
    view.setColorFilter(getColor(view.getContext(), attribute), PorterDuff.Mode.SRC_IN);
}
 
开发者ID:Vavassor,项目名称:Tusky,代码行数:4,代码来源:ThemeUtils.java

示例14: setTint

import android.widget.ImageView; //导入方法依赖的package包/类
public static void setTint(@NonNull ImageView image, @ColorInt int color) {
    image.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:4,代码来源:TintHelper.java

示例15: make

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * Make a themed toast with text, icon, toastBackground and the tint color.
 *
 * @param context The context to use. Usually your {@link android.app.Application}
 *                or {@link android.app.Activity} object.
 * @param text The text to show. Can be formatted text.
 * @param icon The toast icon to show.
 * @param tintColor The toast tint color based on the toastBackground. It will
 *                  automatically check for the contrast to provide best
 *                  visibility.
 * @param backgroundColor The toast toastBackground color.
 * @param duration How long to display the message. Either
 *                 {@link Toast#LENGTH_SHORT} or {@link Toast#LENGTH_LONG}.
 *
 * @return Toast with the supplied parameters. Use {@link Toast#show()}
 *         to display the toast.
 */
public static @NonNull Toast make(@NonNull Context context, @Nullable CharSequence text,
                                  @Nullable Drawable icon, @ColorInt int tintColor,
                                  @ColorInt int backgroundColor, int duration) {
    final Toast toast = new Toast(context);

    final View toastLayout = LayoutInflater.from(context).inflate(
            R.layout.adt_layout_hint, new LinearLayout(context), false);

    final ImageView toastIcon = toastLayout.findViewById(R.id.adt_hint_icon);
    final TextView toastText = toastLayout.findViewById(R.id.adt_hint_text);

    tintColor = DynamicColorUtils.getContrastColor(tintColor, backgroundColor);

    if (icon != null && !disableIcon) {
        if (iconSize != ADT_DEFAULT_ICON_SIZE) {
            toastIcon.getLayoutParams().width = iconSize;
            toastIcon.getLayoutParams().height = iconSize;
            toastIcon.requestLayout();
        }
        toastIcon.setColorFilter(tintColor);
        toastIcon.setImageDrawable(icon);
    } else {
        toastIcon.setVisibility(View.GONE);
    }

    if (textTypeface != null) {
        toastText.setTypeface(textTypeface);
    }
    if (textSize != ADT_DEFAULT_TEXT_SIZE) {
        toastText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    }
    toastText.setTextColor(tintColor);
    toastText.setText(text);

    if (toastBackground != null) {
        DynamicDrawableUtils.setBackground(toastLayout,
                DynamicDrawableUtils.colorizeDrawable(toastBackground,
                        backgroundColor, PorterDuff.Mode.MULTIPLY));
    } else {
        DynamicDrawableUtils.setBackground(toastLayout,
                DynamicDrawableUtils.colorizeDrawable(
                        ContextCompat.getDrawable(context, R.drawable.adt_hint_frame),
                        backgroundColor, PorterDuff.Mode.MULTIPLY));
    }

    toast.setDuration(duration);
    toast.setView(toastLayout);

    return toast;
}
 
开发者ID:pranavpandey,项目名称:dynamic-toasts,代码行数:68,代码来源:DynamicHint.java


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