Java 类android.support.v7.widget.AppCompatImageView 实例源码

项目:africastalking-android    文件:BaseActivity.java   
protected void showInfo(String header, String desc, @Nullable Drawable drawable, boolean error) {
    hideKeyboard();
    AppCompatTextView infoHeader = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_header);
    AppCompatTextView infoDesc = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_desc);
    AppCompatImageView infoImg = (AppCompatImageView) llBottomSheet.findViewById(R.id.info_img);
    if (error) {
        llBottomSheet.findViewById(R.id.info_img).setVisibility(View.GONE);
        ((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Close");
    } else {
        llBottomSheet.findViewById(R.id.info_img).setVisibility(View.VISIBLE);
        ((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Ok");
    }

    infoHeader.setText(header);
    infoDesc.setText(desc);
    if (drawable != null)
        infoImg.setImageDrawable(drawable);
    bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
项目:TYT    文件:SelectPictureActivity.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    FolderViewHolder holder = null;
    if (convertView == null) {
        convertView = View.inflate(mContext, R.layout.item_listview_dir, null);
        holder = new FolderViewHolder();
        holder.id_dir_item_image = (AppCompatImageView) convertView.findViewById(R.id.id_dir_item_image);
        holder.id_dir_item_name = (AppCompatTextView) convertView.findViewById(R.id.id_dir_item_name);
        holder.id_dir_item_count = (AppCompatTextView) convertView.findViewById(R.id.id_dir_item_count);
        holder.choose = (AppCompatImageView) convertView.findViewById(R.id.choose);
        convertView.setTag(holder);
    } else {
        holder = (FolderViewHolder) convertView.getTag();
    }
    ImageFolder item = mDirPaths.get(position);
    mImageLoader.displayImage("file://" + item.getFirstImagePath(), holder.id_dir_item_image, options);
    holder.id_dir_item_count.setText(item.images.size() + "张");
    holder.id_dir_item_name.setText(item.getName());
    holder.choose.setVisibility(currentImageFolder == item ? View.VISIBLE : View.GONE);
    return convertView;
}
项目:PDialogs-Android    文件:HorizontalPicker.java   
private void init() {
    inflate(getContext(), R.layout.recycle_picker, this);

    titlePickerTv = findViewById(R.id.titlePickerTv);
    subTitleTv = findViewById(R.id.subTitleTv);

    AppCompatImageView numberImgv = findViewById(R.id.numberImgv);

    recyclerView = findViewById(R.id.recyclerView);

    titlePickerTv.setText(title);
    titlePickerTv.setTextColor(titleColor);
    subTitleTv.setTextColor(subColor);
    titlePickerTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, titleSize);
    subTitleTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, subSize);

    numberImgv.getLayoutParams().width = itemSize;
    numberImgv.getLayoutParams().height = itemSize;
    numberImgv.setImageResource(pickerIcon);

    itemWidth = itemSize;
    initialView();

}
项目:Sanxing    文件:AchievementsAdapter.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    StatisticsActivity.Achievement achievement = getItem(position);
    if (convertView == null) {
        convertView = LayoutInflater.from(getContext())
                        .inflate(R.layout.achievement_list_template, parent, false);
    }

    AppCompatTextView title = (AppCompatTextView)convertView.findViewById(R.id.achievement_list_item_title);
    AppCompatTextView description = (AppCompatTextView)convertView.findViewById(R.id.achievement_list_item_description);
    AppCompatImageView layer1 = (AppCompatImageView)convertView.findViewById(R.id.medal_layer1);
    AppCompatImageView layer2 = (AppCompatImageView)convertView.findViewById(R.id.medal_layer2);
    AppCompatImageView layer3 = (AppCompatImageView)convertView.findViewById(R.id.medal_layer3);

    if(achievement != null) {
        if(achievement.title != null) title.setText(achievement.title);
        if(achievement.description != null) description.setText(achievement.description);
        layer1.setColorFilter(achievement.getBandColor(), PorterDuff.Mode.SRC_IN);
        layer2.setColorFilter(achievement.getMedalBrightColor(), PorterDuff.Mode.SRC_IN);
        layer3.setColorFilter(achievement.getMedalDarkColor(), PorterDuff.Mode.SRC_IN);
    }

    return convertView;
}
项目:com.ruuvi.station    文件:AddTagAdapter.java   
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
    final RuuviTag tag = getItem(position);

    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_item_add, parent, false);
    }

    ((TextView)convertView.findViewById(R.id.address)).setText(tag.id);
    ((TextView)convertView.findViewById(R.id.rssi)).setText(String.format(getContext().getResources().getString(R.string.signal_reading), tag.rssi));

    AppCompatImageView signalIcon = convertView.findViewById(R.id.signalIcon);
    if (tag.rssi < -80) signalIcon.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.icon_connection_1));
    else if (tag.rssi < -50) signalIcon.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.icon_connection_2));
    else signalIcon.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.icon_connection_3));

    return convertView;
}
项目:garras    文件:NavigationFragment.java   
private void setupUserAvatar(AppCompatImageView avatar, Me.ProfileImage image) {
    int flag = CalendarUtils.festivalFlag();
    if (2 == flag) {
        avatar.setImageResource(R.mipmap.new_year_round);
    } else if (1 == flag) {
        avatar.setImageResource(R.mipmap.new_year_dog2);
    } else {
        if (null == image) {
            avatar.setImageResource(R.mipmap.bg_dark_avatar_male_big_normal);
        } else {
            RequestBuilder<Bitmap> bitmapRequestBuilder = GlideApp.with(getActivity())
                    .asBitmap()
                    .load(image.large)
                    .error(R.mipmap.bg_dark_avatar_male_big_normal)
                    .placeholder(R.mipmap.bg_dark_avatar_male_big_normal)
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
                    .fallback(R.mipmap.bg_dark_avatar_male_big_normal);
            bitmapRequestBuilder.into(avatar);
        }
    }
}
项目:garras    文件:SplashActivity.java   
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LocaleUtils.loadLocale(this);
        setContentView(R.layout.activity_splash);
        AppCompatImageView logo = findViewById(R.id.logo);
        logo.setVisibility(View.VISIBLE);

//        final SpringyAnimator scaleY = new SpringyAnimator(SpringAnimationType.SCALEY, 5, 3, 0.5f, 1);
//        final SpringyAnimator rotate = new SpringyAnimator(SpringAnimationType.ROTATEY, 5, 3, 180, 0);
//        rotate.setDelay(100);
//        scaleY.setDelay(200);
//        rotate.startSpring(logo);
//        scaleY.startSpring(logo);

        new Timer().schedule(new TimerTask() {
            @Override
            public void run() {
                startActivity(new Intent(SplashActivity.this, MainActivity.class));
                finishAfterTransition();
            }
        }, 800);
    }
项目:garras    文件:CollectionAdapter.java   
@Override
protected void convert(BaseViewHolder holder, final Collection item) {
    final CardView layout = holder.getView(R.id.item_layout);

    final AppCompatTextView title = holder.getView(R.id.title_txt);
    final AppCompatTextView count = holder.getView(R.id.count_txt);
    title.setText(String.valueOf(item.title));
    count.setText(count.getContext().getString(R.string.photos, String.valueOf(item.total_photos)));

    final AppCompatImageView image = holder.getView(R.id.item_image);
    Collection.CoverPhoto cp = item.cover_photo;
    mFullRequest.load(getRegularSizeUrl(cp.urls.regular))
            .thumbnail(mThumbRequest.load(cp.urls.thumb))
            .into(image);

    float finalHeight = displaymetrics.widthPixels / ((float) cp.width / (float) cp.height);
    image.setMinimumHeight((int) finalHeight);
    startSaturationAnimation(image.getContext(), image);
    layout.setCardBackgroundColor(computeCardBackgroundColor(cp.color));
}
项目:garras    文件:CollectionAdapter.java   
private void startSaturationAnimation(Context context, final AppCompatImageView target) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        target.setHasTransientState(true);
        final AnimUtils.ObservableColorMatrix matrix = new AnimUtils.ObservableColorMatrix();
        final ObjectAnimator saturation = ObjectAnimator.ofFloat(
                matrix, AnimUtils.ObservableColorMatrix.SATURATION, 0f, 1f);
        saturation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                target.setColorFilter(new ColorMatrixColorFilter(matrix));
            }
        });
        saturation.setDuration(2000);
        saturation.setInterpolator(AnimUtils.getFastOutSlowInInterpolator(context));
        saturation.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                target.clearColorFilter();
                target.setHasTransientState(false);
            }
        });
        saturation.start();
    }
}
项目:garras    文件:PhotoAdapter.java   
private void startSaturationAnimation(Context context, final AppCompatImageView target) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        target.setHasTransientState(true);
        final AnimUtils.ObservableColorMatrix matrix = new AnimUtils.ObservableColorMatrix();
        final ObjectAnimator saturation = ObjectAnimator.ofFloat(
                matrix, AnimUtils.ObservableColorMatrix.SATURATION, 0f, 1f);
        saturation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                target.setColorFilter(new ColorMatrixColorFilter(matrix));
            }
        });
        saturation.setDuration(2000);
        saturation.setInterpolator(AnimUtils.getFastOutSlowInInterpolator(context));
        saturation.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                target.clearColorFilter();
                target.setHasTransientState(false);
            }
        });
        saturation.start();
    }
}
项目:garras    文件:GlideImageLoader.java   
@Override
public View showThumbnail(BigImageView parent, Uri thumbnail, int scaleType) {
    AppCompatImageView thumbnailView = (AppCompatImageView) LayoutInflater.from(parent.getContext())
            .inflate(R.layout.ui_glide_thumbnail, parent, false);
    switch (scaleType) {
        case BigImageView.INIT_SCALE_TYPE_CENTER_CROP:
            thumbnailView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            break;
        case BigImageView.INIT_SCALE_TYPE_CENTER_INSIDE:
            thumbnailView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
            break;
        case BigImageView.INIT_SCALE_TYPE_START:
            thumbnailView.setScaleType(ImageView.ScaleType.FIT_START);
            break;
        default:
            break;
    }
    mRequestManager
            .load(thumbnail)
            .into(thumbnailView);
    return thumbnailView;
}
项目:MTweaks-KernelAdiutorMOD    文件:DropDownView.java   
@Override
public void onCreateView(View view) {
    mTitle = (TextView) view.findViewById(R.id.title);
    mSummary = (TextView) view.findViewById(R.id.summary);
    mArrow = (AppCompatImageView) view.findViewById(R.id.arrow_image);
    mParent = (LinearLayout) view.findViewById(R.id.parent_layout);

    mItemHeight = view.getResources().getDimension(R.dimen.rv_drop_down_item_height);

    mArrow.setRotationX(mExpanded ? 0 : 180);
    setHeight(mExpanded && mItems != null ? Math.round(mItemHeight * mItems.size()) : 0);

    view.findViewById(R.id.title_parent).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mExpanded) {
                collapse();
            } else {
                expand();
            }
        }
    });

    super.onCreateView(view);
}
项目:techstar-shop    文件:ActivitySplashScreen.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash_screen);

    prefManager = new PrefManager(this);

    AppCompatImageView en = (AppCompatImageView)findViewById(R.id.langEn);
    AppCompatImageView mn = (AppCompatImageView)findViewById(R.id.langMn);
    AppCompatImageView cn = (AppCompatImageView)findViewById(R.id.langCn);
    AppCompatImageView ru = (AppCompatImageView)findViewById(R.id.langRu);

    mn.setOnClickListener(this);
    en.setOnClickListener(this);
    cn.setOnClickListener(this);
    ru.setOnClickListener(this);
}
项目:TheMovies    文件:MyBottomNavigationView.java   
private void centerMenuIcon() {
    BottomNavigationMenuView menuView = getBottomMenuView();

    if (menuView != null) {
        for (int i = 0; i < menuView.getChildCount(); i++) {
            BottomNavigationItemView menuItemView = (BottomNavigationItemView) menuView.getChildAt(i);

            AppCompatImageView icon = (AppCompatImageView) menuItemView.getChildAt(0);

            FrameLayout.LayoutParams params = (LayoutParams) icon.getLayoutParams();
            params.gravity = Gravity.CENTER;

            menuItemView.setShiftingMode(true);
        }
    }
}
项目:KernelAdiutor-Mod    文件:DropDownView.java   
@Override
public void onCreateView(View view) {
    mTitle = (TextView) view.findViewById(R.id.title);
    mSummary = (TextView) view.findViewById(R.id.summary);
    mArrow = (AppCompatImageView) view.findViewById(R.id.arrow_image);
    mParent = (LinearLayout) view.findViewById(R.id.parent_layout);

    mItemHeight = view.getResources().getDimension(R.dimen.rv_drop_down_item_height);

    mArrow.setRotationX(mExpanded ? 0 : 180);
    setHeight(mExpanded && mItems != null ? Math.round(mItemHeight * mItems.size()) : 0);

    view.findViewById(R.id.title_parent).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mExpanded) {
                collapse();
            } else {
                expand();
            }
        }
    });

    super.onCreateView(view);
}
项目:Coder    文件:MainActivity.java   
@Override
protected void initActivity(@Nullable Bundle savedInstanceState) {
    presenter = new MainPresenter(this);
    homeBanner = (ImageView) findViewById(iv_home_banner);
    tabLayout = (TabLayout) findViewById(R.id.tab_home_category);
    appBarLayout = (AppBarLayout) findViewById(R.id.appbar);
    viewPager = (ViewPager) findViewById(R.id.vp_home_category);
    floatingActionButton = (FloatingActionButton) findViewById(R.id.fab_home_random);
    coordinatorLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    setting = (AppCompatImageView) findViewById(R.id.iv_home_setting);


    setFabDynamicState();

    homeBanner.setOnClickListener(this);
    floatingActionButton.setOnClickListener(this);
    setting.setOnClickListener(this);


    presenter.getServerData();
    viewPager.setAdapter(new MainPagerAdapter(getSupportFragmentManager()));

    tabLayout.setupWithViewPager(viewPager);

}
项目:Luhn    文件:Luhn.java   
private void showInfo(String header, String desc, @Nullable Drawable drawable, boolean error) {
    hideKeyboard();
    AppCompatTextView infoHeader = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_header);
    AppCompatTextView infoDesc = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_desc);
    AppCompatImageView infoImg = (AppCompatImageView) llBottomSheet.findViewById(R.id.info_img);
    if (error) {
        llBottomSheet.findViewById(R.id.info_img).setVisibility(View.GONE);
        ((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Close");
    } else {
        llBottomSheet.findViewById(R.id.info_img).setVisibility(View.VISIBLE);
        ((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Ok");
    }

    infoHeader.setText(header);
    infoDesc.setText(desc);
    if (drawable != null)
        infoImg.setImageDrawable(drawable);
    bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
项目:IdeaTrackerPlus    文件:ToolbarColorizeHelper.java   
/**
 * It's important to set overflowDescription atribute in styles, so we can grab the reference
 * to the overflow icon. Check: res/values/styles.xml
 *
 * @param activity
 * @param colorFilter
 */
private static void setOverflowButtonColor(final Activity activity, final PorterDuffColorFilter colorFilter) {
    final String overflowDescription = activity.getString(R.string.abc_action_menu_overflow_description);
    final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver();
    viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            final ArrayList<View> outViews = new ArrayList<View>();
            decorView.findViewsWithText(outViews, overflowDescription,
                    View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
            if (outViews.isEmpty()) {
                return;
            }
            AppCompatImageView overflow = (AppCompatImageView) outViews.get(0);
            overflow.setColorFilter(colorFilter);
            removeOnGlobalLayoutListener(decorView, this);
        }
    });
}
项目:QiangHongBao    文件:BottomBarBadge.java   
void adjustPositionAndSize(BottomBarTab tab) {
    AppCompatImageView iconView = tab.getIconView();
    ViewGroup.LayoutParams params = getLayoutParams();

    int size = Math.max(getWidth(), getHeight());
    float xOffset = iconView.getWidth();

    if (tab.getType() == BottomBarTab.Type.TABLET) {
        xOffset /= 1.25;
    }

    setX(iconView.getX() + xOffset);
    setTranslationY(10);

    if (params.width != size || params.height != size) {
        params.width = size;
        params.height = size;
        setLayoutParams(params);
    }
}
项目:QiangHongBao    文件:BottomBarTab.java   
void prepareLayout() {
    int layoutResource;

    layoutResource = getLayoutResource();

    inflate(getContext(), layoutResource, this);
    setOrientation(VERTICAL);
    setGravity(Gravity.CENTER_HORIZONTAL);
    setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    iconView = (AppCompatImageView) findViewById(R.id.bb_bottom_bar_icon);
    iconView.setImageResource(iconResId);

    if (type != Type.TABLET) {
        titleView = (TextView) findViewById(R.id.bb_bottom_bar_title);
        titleView.setText(title);
    }

    updateCustomTextAppearance();
    updateCustomTypeface();
}
项目:MyAnimeViewer    文件:AnimeUtils.java   
public static void viewAnime(Context context, AppCompatImageView imageView, Anime anime) {
    if (context == null) {
        WriteLog.appendLog("viewAnime called with null context");
        return;
    }
    if (anime == null) {
        WriteLog.appendLog("viewAnime called with null data");
        return;
    }
    String transitionName = context.getString(R.string.transition_anime_cover);
    Intent lIntent = new Intent();
    lIntent.setClass(context, AnimeDetailsActivity.class);
    lIntent.putExtra(Constants.ANIME_ID, anime.getId());
    lIntent.putExtra(Constants.ANIME_URL, anime.getUrl());
    //TransitionManager.setTransitionName(imageView, transitionName);
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation((AppCompatActivity) context, Pair.create((View) imageView, transitionName));
    ActivityCompat.startActivity(context, lIntent, options.toBundle());
    if (context instanceof AppCompatActivity) {
        ((AppCompatActivity) context).overridePendingTransition(0, 0);
    }
}
项目:easlider    文件:EAIndicator.java   
private void addIconNormal() {
    View view = LayoutInflater.from(getContext()).inflate(R.layout.indicator_single_icon, holder, false);
    view.setLayoutParams(getItemParams());

    AppCompatImageView imageView = (AppCompatImageView) view.findViewById(R.id.ic_single);
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) imageView.getLayoutParams();
    params.setMargins(indicatorAttr.eai_ic_margin, indicatorAttr.eai_ic_margin, indicatorAttr.eai_ic_margin, indicatorAttr.eai_ic_margin);
    imageView.setLayoutParams(params);
    if (iconNormalResId != 0)
        imageView.setImageResource(iconNormalResId);
    else
        imageView.setImageDrawable(indicatorAttr.eai_ic_src);
    imageView.invalidate();
    holder.addView(view);
    holder.invalidate();
}
项目:RecyclerViewBanner    文件:RecyclerViewBanner.java   
/**
 * 指示器整体由数据列表容量数量的AppCompatImageView均匀分布在一个横向的LinearLayout中构成
 * 使用AppCompatImageView的好处是在Fragment中也使用Compat相关属性
 */
private void createIndicators() {
    mLinearLayout.removeAllViews();
    for (int i = 0; i < mData.size(); i++) {
        AppCompatImageView img = new AppCompatImageView(getContext());
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        lp.leftMargin = mSpace / 2;
        lp.rightMargin = mSpace / 2;
        if (mSize >= dp2px(4)) { // 设置了indicatorSize属性
            lp.width = lp.height = mSize;
        } else {
            // 如果设置的resource.xml没有明确的宽高,默认最小2dp,否则太小看不清
            img.setMinimumWidth(dp2px(2));
            img.setMinimumHeight(dp2px(2));
        }
        img.setImageDrawable(i == 0 ? mSelectedDrawable : mUnselectedDrawable);
        mLinearLayout.addView(img, lp);
    }
}
项目:RecyclerViewBanner    文件:RecyclerViewBanner.java   
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    AppCompatImageView img = new AppCompatImageView(parent.getContext());
    RecyclerView.LayoutParams params = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    img.setLayoutParams(params);
    img.setId(R.id.rvb_banner_image_view_id);
    img.setScaleType(AppCompatImageView.ScaleType.CENTER_CROP);
    img.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (onRvBannerClickListener != null) {
                onRvBannerClickListener.onClick(currentIndex % mData.size());
            }
        }
    });
    return new RecyclerView.ViewHolder(img) {
    };
}
项目:QMUI_Android    文件:QMUIBottomSheet.java   
public QMUIBottomSheetItemView createItemView(Drawable drawable, CharSequence text, Object tag, int subscriptRes) {
    LayoutInflater inflater = LayoutInflater.from(mContext);
    QMUIBottomSheetItemView itemView = (QMUIBottomSheetItemView) inflater.inflate(R.layout.qmui_bottom_sheet_grid_item, null, false);
    TextView titleTV = (TextView) itemView.findViewById(R.id.grid_item_title);
    if (mItemTextTypeFace != null) {
        titleTV.setTypeface(mItemTextTypeFace);
    }
    titleTV.setText(text);

    itemView.setTag(tag);
    itemView.setOnClickListener(this);
    AppCompatImageView imageView = (AppCompatImageView) itemView.findViewById(R.id.grid_item_image);
    imageView.setImageDrawable(drawable);

    if (subscriptRes != 0) {
        ViewStub stub = (ViewStub) itemView.findViewById(R.id.grid_item_subscript);
        View inflated = stub.inflate();
        ((ImageView) inflated).setImageResource(subscriptRes);
    }
    return itemView;
}
项目:MusicX-music-player    文件:ATEUtil.java   
public static void setOverflowButtonColor(@NonNull Activity activity,
                                          @Nullable Toolbar toolbar,
                                          final @ColorInt int color) {
    if (toolbar != null && toolbar.getTag() != null && ATE.IGNORE_TAG.equals(toolbar.getTag()))
        return; // ignore tag was set, don't update the overflow
    final String overflowDescription = activity.getString(R.string.abc_action_menu_overflow_description);
    final View target = toolbar != null ? toolbar :
            (ViewGroup) activity.getWindow().getDecorView();
    final ViewTreeObserver viewTreeObserver = target.getViewTreeObserver();
    viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            final ArrayList<View> outViews = new ArrayList<>();
            target.findViewsWithText(outViews, overflowDescription,
                    View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
            if (outViews.isEmpty()) return;
            final AppCompatImageView overflow = (AppCompatImageView) outViews.get(0);
            overflow.setImageDrawable(TintHelper.createTintedDrawable(overflow.getDrawable(), color));
            removeOnGlobalLayoutListener(target, this);
        }
    });
}
项目:libSwipes    文件:BaseSwipeActionView.java   
private void init() {
    // Inflating the background area
    inflate(getContext(), R.layout.view_base_swipe, BaseSwipeActionView.this);

    swipeContainer = findViewById(R.id.swipeContainer);

    AppCompatImageView leftIconView = (AppCompatImageView) findViewById(R.id.leftIcon);
    leftIconView.setImageResource(getLeftIconResId());
    AppCompatImageView rightIconView = (AppCompatImageView) findViewById(R.id.rightIcon);
    rightIconView.setImageResource(getRightIconResId());

    // Inflating the foreground area
    childContainer = (FrameLayout) findViewById(R.id.childContainer);
    childContainer.setBackgroundColor(Color.CYAN);
    LayoutInflater.from(getContext()).inflate(getOverlayLayoutResId(), childContainer, true);
    childContainer.setOnClickListener(containerClickListenerWrapper);

    minimumXtoHandleEvents = getResources().getDimension(R.dimen.dimen_swipe_minumum_x);

    if (isSwipeEnabled()) {
        initGestureDetector();
    }
}
项目:InstaLikeView    文件:InstaLikeView.java   
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    mImageHeart = new AppCompatImageView(context);
    TypedArray a = context.getTheme().obtainStyledAttributes(
            attrs,
            R.styleable.InstaLikeView,
            defStyleAttr, 0);

    int likeColor = a.getColor(R.styleable.InstaLikeView_likeColor, ContextCompat.getColor(context, R.color.heartColor));
    int likeSrc = a.getResourceId(R.styleable.InstaLikeView_likeSrc, R.drawable.img_heart);
    int likeSize = a.getDimensionPixelSize(R.styleable.InstaLikeView_likeSize, getResources().getDimensionPixelSize(R.dimen.likeSize));


    LayoutParams heartParams = new LayoutParams(likeSize, likeSize);
    heartParams.addRule(CENTER_IN_PARENT, TRUE);

    mImageHeart.setLayoutParams(heartParams);
    mImageHeart.setVisibility(GONE);
    mImageHeart.setImageResource(likeSrc);
    mImageHeart.setColorFilter(likeColor);
    addView(mImageHeart);
}
项目:MaterialFBook    文件:CookingAToast.java   
public static @CheckResult Toast cooking(Context context, CharSequence message_to_show, int text_color, int background, int icon_toast, boolean duration) {

        View view = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.cooking_a_toast, null);
        view.setBackgroundColor(background);

        AppCompatImageView icon = (AppCompatImageView) view.findViewById(R.id.icon);
        icon.setImageResource(icon_toast);

        AppCompatTextView message = (AppCompatTextView) view.findViewById(R.id.message);
        message.setText(message_to_show);
        message.setTextColor(text_color);

        Toast toast = new Toast(context);
        toast.setView(view);
        toast.setGravity(Gravity.FILL_HORIZONTAL | Gravity.BOTTOM, 0, 0);

        if (duration) {
            toast.setDuration(Toast.LENGTH_LONG);
        } else {
            toast.setDuration(Toast.LENGTH_SHORT);
        }

        return toast;
    }
项目:BottomBar    文件:BottomBarBadge.java   
void adjustPositionAndSize(BottomBarTab tab) {
    AppCompatImageView iconView = tab.getIconView();
    ViewGroup.LayoutParams params = getLayoutParams();

    int size = Math.max(getWidth(), getHeight());
    float xOffset = (float) (iconView.getWidth() / 1.25);

    setX(iconView.getX() + xOffset);
    setTranslationY(10);

    if (params.width != size || params.height != size) {
        params.width = size;
        params.height = size;
        setLayoutParams(params);
    }
}
项目:BottomBar    文件:BottomBarTab.java   
void prepareLayout() {
    inflate(getContext(), getLayoutResource(), this);
    setOrientation(VERTICAL);
    setGravity(isTitleless? Gravity.CENTER : Gravity.CENTER_HORIZONTAL);
    setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    setBackgroundResource(MiscUtils.getDrawableRes(getContext(), R.attr.selectableItemBackgroundBorderless));

    iconView = (AppCompatImageView) findViewById(R.id.bb_bottom_bar_icon);
    iconView.setImageResource(iconResId);

    if (type != Type.TABLET && !isTitleless) {
        titleView = (TextView) findViewById(R.id.bb_bottom_bar_title);
        titleView.setVisibility(VISIBLE);

        if (type == Type.SHIFTING) {
            findViewById(R.id.spacer).setVisibility(VISIBLE);
        }

        updateTitle();
    }

    updateCustomTextAppearance();
    updateCustomTypeface();
}
项目:MoonlightNote    文件:BaseFragment.java   
/**
 * 更改toolbar三个点颜色
 *
 * @param activity Activity
 * @param color    颜色
 */
public static void setOverflowButtonColor(Activity activity, final int color) {
    @SuppressLint("PrivateResource") final String overflowDescription =
            activity.getString(R.string.abc_action_menu_overflow_description);
    final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver();
    viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            final ArrayList<View> outViews = new ArrayList<>();
            decorView.findViewsWithText(outViews, overflowDescription, View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
            if (outViews.isEmpty()) {
                return;
            }
            AppCompatImageView overflow = (AppCompatImageView) outViews.get(0);
            overflow.setColorFilter(color);
            removeOnGlobalLayoutListener(decorView, this);
        }
    });
}
项目:app-theme-engine-master    文件:Util.java   
public static void setOverflowButtonColor(@NonNull Activity activity, final @ColorInt int color) {
    final String overflowDescription = activity.getString(R.string.abc_action_menu_overflow_description);
    final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver();
    viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            final ArrayList<View> outViews = new ArrayList<>();
            decorView.findViewsWithText(outViews, overflowDescription,
                    View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
            if (outViews.isEmpty()) return;
            final AppCompatImageView overflow = (AppCompatImageView) outViews.get(0);
            TintHelper.tintDrawable(overflow.getDrawable(), color);
            removeOnGlobalLayoutListener(decorView, this);
        }
    });
}
项目:polar-dashboard    文件:Utils.java   
public static void setOverflowButtonColor(@NonNull Activity activity, final @ColorInt int color) {
  @SuppressLint("PrivateResource")
  final String overflowDescription =
      activity.getString(R.string.abc_action_menu_overflow_description);
  final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
  final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver();
  viewTreeObserver.addOnGlobalLayoutListener(
      new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
          final ArrayList<View> outViews = new ArrayList<>();
          decorView.findViewsWithText(
              outViews, overflowDescription, View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
          if (outViews.isEmpty()) {
            return;
          }
          final AppCompatImageView overflow = (AppCompatImageView) outViews.get(0);
          overflow.setImageDrawable(
              TintUtils.createTintedDrawable(overflow.getDrawable(), color));
          removeOnGlobalLayoutListener(decorView, this);
        }
      });
}
项目:Puff-Android    文件:DetailActivity.java   
private void wireUpViews(){
    tvAccount = (AppCompatTextView) findViewById(R.id.account);
    tvPasswd = (AppCompatTextView) findViewById(R.id.password);
    tvAdditional = (AppCompatTextView) findViewById(R.id.additional);
    tvTitle = (AppCompatTextView) findViewById(R.id.id_name);
    image = (AppCompatImageView) findViewById(R.id.account_image);
    tvWebSite = (AppCompatTextView) findViewById(R.id.id_website_link);
    tvWebSiteTitle = (AppCompatTextView) findViewById(R.id.website_title);
    webSiteContainer = (LinearLayout) findViewById(R.id.website_container);
    tvLastAccess = (AppCompatTextView) findViewById(R.id.last_accessed);

    webSiteContainer.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String url = account.getWebsite();
            if (!url.startsWith("http://") && !url.startsWith("https://"))
                url = "http://" + url;

            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            startActivity(i);
        }
    });
}
项目:RadioRealButton    文件:RadioRealButton.java   
private void initViews() {
    setLayoutParams(new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1));
    setOrientation(HORIZONTAL);
    setGravity(Gravity.CENTER);

    imageView = new AppCompatImageView(getContext());
    imageView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) {{
        gravity = Gravity.CENTER;
    }});
    setDrawableAttrs();
    addView(imageView);

    textView = new AppCompatTextView(getContext());
    textView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) {{
        gravity = Gravity.CENTER;
    }});
    setTextAttrs();
    addView(textView);
}
项目:RadioRealButton    文件:RadioRealButton.java   
private void updatePadding(View view, boolean hasOtherView) {
    if (null == view)
        return;

    int[] paddings = {paddingLeft, paddingTop, paddingRight, paddingBottom};

    if (hasOtherView) {
        int g = drawableGravity.getIntValue();
        if (view instanceof AppCompatImageView) {
            g = g > 1 ? g - 2 : g + 2;
        }
        paddings[g] = drawablePadding / 2;
    }

    MarginLayoutParams params = (MarginLayoutParams) view.getLayoutParams();
    params.setMargins(paddings[0], paddings[1], paddings[2], paddings[3]);
}
项目:app-theme-engine    文件:ATEUtil.java   
public static void setOverflowButtonColor(@NonNull Activity activity,
                                          @Nullable Toolbar toolbar,
                                          final @ColorInt int color) {
    if (toolbar != null && toolbar.getTag() != null && ATE.IGNORE_TAG.equals(toolbar.getTag()))
        return; // ignore tag was set, don't update the overflow
    final String overflowDescription = activity.getString(R.string.abc_action_menu_overflow_description);
    final View target = toolbar != null ? toolbar :
            (ViewGroup) activity.getWindow().getDecorView();
    final ViewTreeObserver viewTreeObserver = target.getViewTreeObserver();
    viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            final ArrayList<View> outViews = new ArrayList<>();
            target.findViewsWithText(outViews, overflowDescription,
                    View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
            if (outViews.isEmpty()) return;
            final AppCompatImageView overflow = (AppCompatImageView) outViews.get(0);
            overflow.setImageDrawable(TintHelper.createTintedDrawable(overflow.getDrawable(), color));
            removeOnGlobalLayoutListener(target, this);
        }
    });
}
项目:nono-android    文件:RegisterActivity.java   
void getDefinition()
{
    getSupportFragmentManager().beginTransaction().replace(R.id.container,registerAccountFragment).commit();
    progBarRegister=(ProgressBar)this.findViewById(R.id.register_progress);
    register_fab = (FloatingActionButton)this.findViewById(R.id.register_fab);
    next_btn = (AppCompatImageView)findViewById(R.id.next_btn);
    container = (FrameLayout)findViewById(R.id.container);
    info_tv = (TextView)findViewById(R.id.info_tv);
    register_fab.setOnClickListener(this);
    next_btn.setOnClickListener(this);
    bg = (ImageView)findViewById(R.id.bg);
    Bitmap image = null;
    image = BitmapFactory.decodeResource(getResources(),R.drawable.butiful_bg);
    ImageHelper.fastblurSrc( image, 12);
    bg.setImageBitmap(image);
}
项目:nono-android    文件:PhotoLayout.java   
private void initPreContainer(){
    preContainer=new LinearLayout(getContext());
    preContainer.setOrientation(LinearLayout.HORIZONTAL);
    LayoutParams lp=new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.gravity=Gravity.CENTER_VERTICAL;
    preContainer.setLayoutParams(lp);
    preContainer.setOnClickListener(this);
    AppCompatImageView tmpImageView=new AppCompatImageView(getContext());
    tmpImageView.setBackgroundResource(R.mipmap.ic_image_black_24dp);
    AppCompatTextView tmpTextView=new AppCompatTextView(getContext());
    LinearLayout.LayoutParams lp1=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp1.gravity=Gravity.CENTER_VERTICAL;
    tmpImageView.setLayoutParams(lp1);
    tmpTextView.setLayoutParams(lp1);
    tmpTextView.setText(getContext().getString(R.string.select_photo));
    preContainer.addView(tmpImageView);
    preContainer.addView(tmpTextView);
    this.addView(preContainer);
}