类androidx.appcompat.widget.AppCompatImageView源码实例Demo

下面列出了怎么用androidx.appcompat.widget.AppCompatImageView的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: weather   文件: AppUtil.java
/**
 * Set icon to imageView according to weather code status
 *
 * @param context     instance of {@link Context}
 * @param imageView   instance of {@link android.widget.ImageView}
 * @param weatherCode code of weather status
 */
public static void setWeatherIcon(Context context, AppCompatImageView imageView, int weatherCode) {
  if (weatherCode / 100 == 2) {
    Glide.with(context).load(R.drawable.ic_storm_weather).into(imageView);
  } else if (weatherCode / 100 == 3) {
    Glide.with(context).load(R.drawable.ic_rainy_weather).into(imageView);
  } else if (weatherCode / 100 == 5) {
    Glide.with(context).load(R.drawable.ic_rainy_weather).into(imageView);
  } else if (weatherCode / 100 == 6) {
    Glide.with(context).load(R.drawable.ic_snow_weather).into(imageView);
  } else if (weatherCode / 100 == 7) {
    Glide.with(context).load(R.drawable.ic_unknown).into(imageView);
  } else if (weatherCode == 800) {
    Glide.with(context).load(R.drawable.ic_clear_day).into(imageView);
  } else if (weatherCode == 801) {
    Glide.with(context).load(R.drawable.ic_few_clouds).into(imageView);
  } else if (weatherCode == 803) {
    Glide.with(context).load(R.drawable.ic_broken_clouds).into(imageView);
  } else if (weatherCode / 100 == 8) {
    Glide.with(context).load(R.drawable.ic_cloudy_weather).into(imageView);
  }
}
 
@Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view = inflater.inflate(R.layout.spinner_item, null);

        try {
            AppCompatImageView icon = view.findViewById(R.id.imageView);
//            icon.setImageDrawable(rows.get(i).icon);
            TextView name = (TextView) view.findViewById(R.id.textView);
            name.setText(rows.get(i).text);
            if (rows.get(i).url != null && !rows.get(i).url.equalsIgnoreCase("")) {
                Picasso
                        .with(inflater.getContext())
                        .load(rows.get(i).url)
                        .placeholder(R.drawable.ic_curr_empty)
                        .error(R.drawable.ic_curr_empty)
                        .into(icon);
            } else {
                icon.setImageDrawable(rows.get(i).icon);
            }
        } catch (IndexOutOfBoundsException iobe) {
            iobe.printStackTrace();
        }

        return view;
    }
 
源代码3 项目: onpc   文件: MainNavigationDrawer.java
private void updateNavigationHeader(final String versionName)
{
    for (int i = 0; i < navigationView.getHeaderCount(); i++)
    {
        final TextView versionInfo = navigationView.getHeaderView(i).findViewById(R.id.navigation_view_header_version);
        if (versionInfo != null)
        {
            versionInfo.setText(versionName);
        }

        final AppCompatImageView logo = navigationView.getHeaderView(i).findViewById(R.id.drawer_header);
        if (logo != null)
        {
            Utils.setImageViewColorAttr(activity, logo, R.attr.colorAccent);
        }
    }
}
 
源代码4 项目: onpc   文件: MainNavigationDrawer.java
private void updateItem(@NonNull final MenuItem m, final @DrawableRes int iconId, final String title, final ButtonListener editListener)
{
    if (m.getActionView() != null && m.getActionView() instanceof LinearLayout)
    {
        final LinearLayout l = (LinearLayout)m.getActionView();
        ((AppCompatImageView) l.findViewWithTag("ICON")).setImageResource(iconId);
        ((AppCompatTextView)l.findViewWithTag("TEXT")).setText(title);
        final AppCompatImageButton editBtn = l.findViewWithTag("EDIT");
        if (editListener != null)
        {
            editBtn.setVisibility(View.VISIBLE);
            editBtn.setOnClickListener(v -> editListener.onEditItem());
            Utils.setButtonEnabled(activity, editBtn, true);
        }
        else
        {
            editBtn.setVisibility(View.GONE);
        }
    }
    m.setVisible(true);
}
 
源代码5 项目: mimi-reader   文件: RepliesListAdapter.java
public ViewHolderItem(final View v) {
    threadId = (TextView) v.findViewById(R.id.thread_id);
    userName = (TextView) v.findViewById(R.id.user_name);
    postTime = (TextView) v.findViewById(R.id.timestamp);
    userId = (TextView) v.findViewById(R.id.user_id);
    tripCode = (TextView) v.findViewById(R.id.tripcode);
    subject = (TextView) v.findViewById(R.id.subject);
    comment = (TextView) v.findViewById(R.id.comment);
    thumbUrl = (AppCompatImageView) v.findViewById(R.id.thumbnail);
    gotoPost = (TextView) v.findViewById(R.id.goto_post);
    repliesText = (TextView) v.findViewById(R.id.replies_number);
    thumbnailContainer = (ViewGroup) v.findViewById(R.id.thumbnail_container);
    flagIcon = (AppCompatImageView) v.findViewById(R.id.flag_icon);

    comment.setMovementMethod(LongClickLinkMovementMethod.getInstance());
}
 
源代码6 项目: GeometricWeather   文件: WechatDonateDialog.java
@NonNull
@SuppressLint("InflateParams")
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    View view = LayoutInflater.from(getActivity())
            .inflate(R.layout.dialog_donate_wechat, null, false);

    AppCompatImageView image = view.findViewById(R.id.dialog_donate_wechat_img);
    Glide.with(getActivity())
            .load(R.drawable.donate_wechat)
            .into(image);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(view);
    return builder.create();
}
 
源代码7 项目: GeometricWeather   文件: AnimatableIconView.java
private void initialize(TypedArray attributes) {
    int innerMargin = attributes.getDimensionPixelSize(
            R.styleable.AnimatableIconView_inner_margins, 0);
    LayoutParams params = new LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    params.setMargins(innerMargin, innerMargin, innerMargin, innerMargin);

    iconImageViews = new AppCompatImageView[] {
            new AppCompatImageView(getContext()),
            new AppCompatImageView(getContext()),
            new AppCompatImageView(getContext())
    };
    iconAnimators = new Animator[] {null, null, null};

    for (int i = iconImageViews.length - 1; i >= 0; i --) {
        addView(iconImageViews[i], params);
    }
}
 
源代码8 项目: GeometricWeather   文件: MinimalIconDialog.java
private void initWidget(View view) {
    if (getActivity() == null) {
        return;
    }

    AppCompatImageView xmlIcon = view.findViewById(R.id.dialog_minimal_icon_xmlIcon);
    xmlIcon.setImageDrawable(xmlIconDrawable);

    TextView titleView = view.findViewById(R.id.dialog_minimal_icon_title);
    titleView.setText(title);

    AppCompatImageView lightIconView = view.findViewById(R.id.dialog_minimal_icon_lightIcon);
    lightIconView.setImageDrawable(lightDrawable);

    AppCompatImageView greyIconView = view.findViewById(R.id.dialog_minimal_icon_greyIcon);
    greyIconView.setImageDrawable(greyDrawable);

    AppCompatImageView darkIconView = view.findViewById(R.id.dialog_minimal_icon_darkIcon);
    darkIconView.setImageDrawable(darkDrawable);
}
 
源代码9 项目: Mysplash   文件: LoginActivity.java
private void initWidget() {
    swipeBackView.setOnSwipeListener(this);

    AppCompatImageView icon = findViewById(R.id.activity_login_icon);
    ImageHelper.loadImage(this, icon, R.drawable.ic_launcher);

    Button loginBtn = findViewById(R.id.activity_login_loginBtn);
    Button joinBtn = findViewById(R.id.activity_login_joinBtn);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        if (ThemeManager.getInstance(this).isLightTheme()) {
            loginBtn.setBackgroundResource(R.color.colorPrimaryDark_dark);
            joinBtn.setBackgroundResource(R.color.colorPrimaryDark_light);
        } else {
            loginBtn.setBackgroundResource(R.color.colorPrimaryDark_light);
            joinBtn.setBackgroundResource(R.color.colorPrimaryDark_dark);
        }
    } else {
        loginBtn.setBackgroundResource(R.drawable.button_login);
        joinBtn.setBackgroundResource(R.drawable.button_join);
    }

    progressContainer.setVisibility(View.GONE);
}
 
源代码10 项目: Mysplash   文件: CircularProgressIcon.java
private void initialize() {
    image = new AppCompatImageView(getContext());
    image.setBackgroundColor(Color.TRANSPARENT);
    LayoutParams imageParams = new LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT
    );
    int imageMargin = getResources().getDimensionPixelSize(R.dimen.little_margin);
    imageParams.setMargins(imageMargin, imageMargin, imageMargin, imageMargin);
    image.setLayoutParams(imageParams);
    addView(image);

    progress = new CircularProgressView(getContext());
    progress.setIndeterminate(true);
    progress.setColor(Color.WHITE);
    LayoutParams progressParams = new LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT
    );
    int progressMargin = (int) new DisplayUtils(getContext()).dpToPx(5);
    progressParams.setMargins(progressMargin, progressMargin, progressMargin, progressMargin);
    progress.setLayoutParams(progressParams);
    addView(progress);

    forceSetResultState(android.R.color.transparent);
}
 
源代码11 项目: SmartFlasher   文件: MainActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    // Initialize App Theme & FaceBook Ads
    Utils.initializeAppTheme(this);
    Utils.getInstance().initializeFaceBookAds(this);
    super.onCreate(savedInstanceState);
    // Set App Language
    Utils.setLanguage(this);
    setContentView(R.layout.activity_main);

    AppCompatImageView unsupported = findViewById(R.id.no_root_Image);
    TextView textView = findViewById(R.id.no_root_Text);
    TabLayout tabLayout = findViewById(R.id.tabLayoutID);
    mViewPager = findViewById(R.id.viewPagerID);

    if (!RootUtils.rootAccess()) {
        textView.setText(getString(R.string.no_root));
        unsupported.setImageDrawable(Utils.getColoredIcon(R.drawable.ic_help, this));
        return;
    }

    PagerAdapter adapter = new PagerAdapter(getSupportFragmentManager());
    adapter.AddFragment(new FlasherFragment(), getString(R.string.flasher));
    adapter.AddFragment(new BackupFragment(), getString(R.string.backup));
    adapter.AddFragment(new AboutFragment(), getString(R.string.about));

    mViewPager.setAdapter(adapter);
    tabLayout.setupWithViewPager(mViewPager);
}
 
源代码12 项目: AndroidProject   文件: GuidePagerAdapter.java
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
    AppCompatImageView imageView = new AppCompatImageView(container.getContext());
    imageView.setPaddingRelative(0, 0, 0,
            (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 50, container.getContext().getResources().getDisplayMetrics()));
    imageView.setImageResource(DRAWABLES[position]);
    container.addView(imageView);
    return imageView;
}
 
@NonNull
private ExpansionHeader createExpansionHeader() {
    final ExpansionHeader expansionHeader = new ExpansionHeader(this);
    expansionHeader.setBackgroundColor(Color.WHITE);

    expansionHeader.setPadding(dpToPx(this, 16), dpToPx(this, 8), dpToPx(this, 16), dpToPx(this, 8));

    final RelativeLayout layout = new RelativeLayout(this);
    expansionHeader.addView(layout, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); //equivalent to addView(linearLayout)

    //image
    final ImageView expansionIndicator = new AppCompatImageView(this);
    expansionIndicator.setImageResource(R.drawable.ic_expansion_header_indicator_grey_24dp);
    final RelativeLayout.LayoutParams imageLayoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    imageLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    imageLayoutParams.addRule(RelativeLayout.CENTER_VERTICAL);
    layout.addView(expansionIndicator, imageLayoutParams);

    //label
    final TextView text = new TextView(this);
    text.setText("Trip name");
    text.setTextColor(Color.parseColor("#3E3E3E"));

    final RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    textLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    textLayoutParams.addRule(RelativeLayout.CENTER_VERTICAL);

    layout.addView(text, textLayoutParams);

    expansionHeader.setExpansionHeaderIndicator(expansionIndicator);
    return expansionHeader;
}
 
源代码14 项目: HaoReader   文件: AppCompat.java
public static void useSimpleStyleForSearchView(SearchView searchView, String hint){
    AppCompatImageView search = searchView.findViewById(androidx.appcompat.R.id.search_mag_icon);
    search.setImageDrawable(null);
    LinearLayout plate = searchView.findViewById(R.id.search_plate);
    plate.setBackground(null);
    AppCompatImageView close = searchView.findViewById(R.id.search_close_btn);
    AppCompat.setTint(close, searchView.getResources().getColor(R.color.colorBarText));
    SearchView.SearchAutoComplete searchAutoComplete = searchView.findViewById(R.id.search_src_text);
    searchAutoComplete.setHint(hint);
}
 
源代码15 项目: KToast   文件: KToast.java
/**
 * Normal type toast with icon.
 * @param activity
 * @param message
 * @param gravity
 * @param duration
 * @param icon
 */
@SuppressLint("WrongViewCast")
public static void normalToast(final Activity activity, String message, final int gravity, int duration, @DrawableRes int icon){
    final View view = (activity.getLayoutInflater().inflate(R.layout.layout_normal_toast, null));

    ((TextView)view.findViewById(R.id.txtNormalToast)).setText(message);
    view.findViewById(R.id.normalToastImg).setVisibility(View.VISIBLE);
    ((AppCompatImageView)view.findViewById(R.id.normalToastImg)).setImageResource(icon);

    if (duration == LENGTH_AUTO){
        duration = Util.toastTime(message);
    }

    new CountDownTimer(Math.max(duration+1000, 1000), 2000){
        @Override
        public void onFinish() {

        }

        @Override
        public void onTick(long millisUntilFinished) {
            Toast toast = new Toast(activity);
            toast.setGravity(gravity, 0, 0);
            toast.setDuration(Toast.LENGTH_SHORT);
            toast.setView(view);
            toast.show();
        }
    }.start();
}
 
源代码16 项目: KToast   文件: KToast.java
/**
 * Custom toast background color and icon.
 * @param activity
 * @param message
 * @param gravity
 * @param duration
 * @param toastColor
 * @param icon
 */
@SuppressLint("WrongViewCast")
public static void customColorToast(final Activity activity, String message, final int gravity, int duration, @ColorRes int toastColor, @DrawableRes int icon){
    final View view = (activity.getLayoutInflater().inflate(R.layout.layout_custom_toast, null));

    ((TextView)view.findViewById(R.id.txtCustomToast)).setText(message);

    Drawable customBackground = view.getResources().getDrawable(R.drawable.background_custom_toast);
    customBackground.setColorFilter(ContextCompat.getColor(view.getContext(), toastColor), PorterDuff.Mode.ADD);

    view.findViewById(R.id.customToastLyt).setBackground(customBackground);

    view.findViewById(R.id.customToastImg).setVisibility(View.VISIBLE);
    ((AppCompatImageView)view.findViewById(R.id.customToastImg)).setImageResource(icon);

    if (duration == LENGTH_AUTO){
        duration = Util.toastTime(message);
    }

    new CountDownTimer(Math.max(duration+1000, 1000), 2000){
        @Override
        public void onFinish() {

        }

        @Override
        public void onTick(long millisUntilFinished) {
            Toast toast = new Toast(activity);
            toast.setGravity(gravity, 0, 0);
            toast.setDuration(Toast.LENGTH_SHORT);
            toast.setView(view);
            toast.show();
        }
    }.start();
}
 
源代码17 项目: CrazyDaily   文件: PhotoPickerAdapter.java
@Override
protected void convert(@NonNull BaseViewHolder holder, MediaEntity item) {
    AppCompatImageView data = holder.getView(R.id.item_photo_picker_data, AppCompatImageView.class);
    ImageLoader.load(mContext, item.getData(), R.mipmap.ic_launcher, data);
    // 选中
    AppCompatTextView select = holder.getView(R.id.item_photo_picker_select, AppCompatTextView.class);
    final int index = item.getIndex();
    if (index > 0) {
        // 选中
        select.setSelected(true);
        select.setText(String.valueOf(index));
    } else {
        select.setSelected(false);
        select.setText(R.string.ic_tick);
    }
    View video = holder.getView(R.id.item_photo_picker_video);
    // 视频信息
    final long duration = item.getDuration();
    if (duration > 0) {
        // 视频
        video.setVisibility(View.VISIBLE);
        AppCompatTextView durationView = holder.getView(R.id.item_photo_picker_duration, AppCompatTextView.class);
        durationView.setText(StringUtil.handleTimeStringByMilli(duration));
    } else {
        video.setVisibility(View.GONE);
    }
    // 监听
    holder.getView(R.id.item_photo_picker_select_wrap).setOnClickListener(v -> {
        if (mOnItemSelectClickListener != null) {
            mOnItemSelectClickListener.onItemSelectClick(item);
        }
    });
    holder.itemView.setOnClickListener(v -> {
        if (mOnItemClickListener != null) {
            mOnItemClickListener.onItemClick(item);
        }
    });
}
 
源代码18 项目: SmartPack-Kernel-Manager   文件: ContributorView.java
@Override
public void onCreateView(View view) {
    super.onCreateView(view);

    AppCompatImageView image = view.findViewById(R.id.image);
    TextView name = view.findViewById(R.id.name);
    TextView contributions = view.findViewById(R.id.contributions);

    ViewUtils.loadImagefromUrl(mContributor.getAvatarUrl(), image, 200, 200);
    name.setText(mContributor.getLogin());
    contributions.setText(view.getResources().getString(R.string.commits, mContributor.getContributions()));

    view.setOnClickListener(v -> Utils.launchUrl(mContributor.getHtmlUrl(), v.getContext()));
}
 
源代码19 项目: AppOpsX   文件: ExpandableItemIndicator.java
@Override
public void onInit(Context context, AttributeSet attrs, int defStyleAttr,
    ExpandableItemIndicator thiz) {
  View v = LayoutInflater.from(context)
      .inflate(R.layout.widget_expandable_item_indicator, thiz, true);
  mImageView = (AppCompatImageView) v.findViewById(R.id.image_view);
}
 
源代码20 项目: SimplicityBrowser   文件: BaseActivity.java
public void getUserInfo(AppCompatImageView imageView){
    if (currentUser != null) {
        if (currentUser.getPhotoUrl() != null) {
            Glide.with(this)
                    .load(currentUser.getPhotoUrl().toString())
                    .apply(RequestOptions.circleCropTransform()
                    .diskCacheStrategy(DiskCacheStrategy.ALL))
                    .into(imageView);
        }
    }

}
 
源代码21 项目: tindroid   文件: AccountInfoFragment.java
@Override
public void updateFormValues(final AppCompatActivity activity, final MeTopic<VxCard> me) {
    if (activity == null) {
        return;
    }

    ((TextView) activity.findViewById(R.id.topicAddress)).setText(Cache.getTinode().getMyId());

    String fn = null;
    if (me != null) {
        VxCard pub = me.getPub();
        if (pub != null) {
            fn = pub.fn;
            final Bitmap bmp = pub.getBitmap();
            if (bmp != null) {
                ((AppCompatImageView) activity.findViewById(R.id.imageAvatar))
                        .setImageDrawable(new RoundImageDrawable(getResources(), bmp));
            }
        }
    }

    final TextView title = activity.findViewById(R.id.topicTitle);
    if (!TextUtils.isEmpty(fn)) {
        title.setText(fn);
        title.setTypeface(null, Typeface.NORMAL);
        title.setTextIsSelectable(true);
    } else {
        title.setText(R.string.placeholder_contact_title);
        title.setTypeface(null, Typeface.ITALIC);
        title.setTextIsSelectable(false);
    }
}
 
源代码22 项目: Mysplash   文件: IntroduceActivity.java
@SuppressLint("InflateParams")
private void initPage() {
    List<View> pageList = new ArrayList<>();
    List<String> titleList = new ArrayList<>();
    for (int i = 0; i < introduceModelList.size(); i ++) {
        View v = LayoutInflater.from(this).inflate(R.layout.container_introduce, null);

        TextView title = v.findViewById(R.id.container_introduce_title);
        title.setText(introduceModelList.get(i).title);

        AppCompatImageView image = v.findViewById(R.id.container_introduce_image);
        ImageHelper.loadImage(this, image, introduceModelList.get(i).imageRes);

        TextView description = v.findViewById(R.id.container_introduce_description);
        description.setText(introduceModelList.get(i).description);

        setPageButtonStyle(v, i);

        pageList.add(v);
        titleList.add(introduceModelList.get(i).title);
    }

    PagerAdapter adapter = new PagerAdapter(viewPager, pageList, titleList);

    viewPager.setAdapter(adapter);
    viewPager.addOnPageChangeListener(this);
}
 
源代码23 项目: Mysplash   文件: SelectCollectionDialog.java
private void initWidget(View v) {
    setCancelable(true);

    AppCompatImageView cover = v.findViewById(R.id.dialog_select_collection_cover);
    cover.setVisibility(View.GONE);

    progressContainer.setVisibility(View.GONE);
    selectorContainer.setVisibility(View.VISIBLE);

    refreshLayout.setColorSchemeColors(ThemeManager.getContentColor(requireActivity()));
    refreshLayout.setProgressBackgroundColorSchemeColor(ThemeManager.getRootColor(requireActivity()));
    refreshLayout.setRefreshEnabled(false);
    refreshLayout.setLoadEnabled(false);

    recyclerView.setLayoutManager(new LinearLayoutManager(requireActivity(), RecyclerView.VERTICAL, false));
    recyclerView.setAdapter(adapter);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        recyclerView.addOnScrollListener(new ElevationScrollListener());
    }
    recyclerView.addOnScrollListener(new LoadScrollListener());

    updatePhotoAdapter();

    creatorContainer.setVisibility(View.GONE);

    nameTxt.setOnFocusChangeListener((v1, hasFocus) -> nameTxtContainer.setError(null));
}
 
源代码24 项目: Kore   文件: RatingBar.java
private FrameLayout createStar(Context context, AttributeSet attrs, int defStyle) {
    FrameLayout frameLayout = new FrameLayout(getContext());
    frameLayout.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));

    AppCompatImageView ivStarBackground = new AppCompatImageView(context, attrs, defStyle);
    ivStarBackground.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));
    ivStarBackground.setImageResource(iconResourceId);
    ivStarBackground.setAdjustViewBounds(true);
    ImageViewCompat.setImageTintList(ivStarBackground, ColorStateList.valueOf(backgroundColor));
    frameLayout.addView(ivStarBackground);

    ClipDrawable clipDrawable = new ClipDrawable(
            ContextCompat.getDrawable(context, iconResourceId),
            Gravity.START,
            ClipDrawable.HORIZONTAL);

    AppCompatImageView ivStarForeground = new AppCompatImageView(context, attrs, defStyle);
    ivStarForeground.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));
    ivStarForeground.setImageDrawable(clipDrawable);
    ivStarForeground.setAdjustViewBounds(true);
    ImageViewCompat.setImageTintList(ivStarForeground, ColorStateList.valueOf(foregroundColor));
    frameLayout.addView(ivStarForeground);

    clipDrawables.add((ClipDrawable) ivStarForeground.getDrawable());

    return frameLayout;
}
 
@Override
public void onBindViewHolder(PreferenceViewHolder holder)
{
    super.onBindViewHolder(holder);

    backgroundPreview = (AppCompatImageView)holder.findViewById(R.id.dialog_color_chooser_pref_background_preview);
    colorPreview = (AppCompatImageView)holder.findViewById(R.id.dialog_color_chooser_pref_color_preview);

    setColorInWidget();
}
 
源代码26 项目: MaterialBanner   文件: Banner.java
private void initViewGroup(Context context) {
    // CONTENT CONTAINER
    LayoutParams layoutParams = new LayoutParams(MATCH_PARENT, WRAP_CONTENT);

    mContentContainer = new RelativeLayout(context);
    mContentContainer.setId(R.id.mb_container_content);
    mContentContainer.setLayoutParams(layoutParams);

    // ICON VIEW
    RelativeLayout.LayoutParams relativeLayoutParams = new RelativeLayout.LayoutParams(
            mIconSize, mIconSize);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        relativeLayoutParams.setMarginStart(mIconMarginStart);
        relativeLayoutParams.addRule(ALIGN_PARENT_START, TRUE);
    } else {
        relativeLayoutParams.leftMargin = mIconMarginStart;
        relativeLayoutParams.addRule(ALIGN_PARENT_LEFT, TRUE);
    }

    mIconView = new AppCompatImageView(context);
    mIconView.setId(R.id.mb_icon);
    mIconView.setLayoutParams(relativeLayoutParams);
    mIconView.setVisibility(GONE);

    // MESSAGE VIEW
    relativeLayoutParams = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        relativeLayoutParams.setMarginStart(mMessageMarginStart);
        relativeLayoutParams.addRule(ALIGN_PARENT_START, TRUE);
    } else {
        relativeLayoutParams.leftMargin = mMessageMarginStart;
        relativeLayoutParams.addRule(ALIGN_PARENT_LEFT, TRUE);
    }

    mMessageView = new MessageView(context);
    mMessageView.setId(R.id.mb_message);
    mMessageView.setLayoutParams(relativeLayoutParams);

    // BUTTONS CONTAINER
    relativeLayoutParams = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        relativeLayoutParams.addRule(ALIGN_PARENT_END, TRUE);
    } else {
        relativeLayoutParams.addRule(ALIGN_PARENT_RIGHT, TRUE);
    }

    mButtonsContainer = new ButtonsContainer(context);
    mButtonsContainer.setId(R.id.mb_container_buttons);
    mButtonsContainer.setLayoutParams(relativeLayoutParams);

    mLeftButton = mButtonsContainer.getLeftButton();
    mRightButton = mButtonsContainer.getRightButton();

    // LINE
    layoutParams = new LayoutParams(MATCH_PARENT, mLineHeight);

    mLine = new View(context);
    mLine.setId(R.id.mb_line);
    mLine.setLayoutParams(layoutParams);

    addView(mContentContainer);
    addView(mLine);

    mContentContainer.addView(mIconView);
    mContentContainer.addView(mMessageView);
    mContentContainer.addView(mButtonsContainer);
}
 
源代码27 项目: CircleFloatBar   文件: FloatbarService.java
private void initView() {

        hideMenuView = LayoutInflater.from(this).inflate(R.layout.dismiss_menu, null);
        imHidingMenu = hideMenuView.findViewById(R.id.btn_menu);


        showMenuView = LayoutInflater.from(this).inflate(R.layout.show_menu, null);
        circleLayout = showMenuView.findViewById(R.id.circle_layout);

        imHome = showMenuView.findViewById(R.id.im_home);
        imTask = showMenuView.findViewById(R.id.im_task);
        imWindows = showMenuView.findViewById(R.id.im_windows);
        imReturn = showMenuView.findViewById(R.id.im_return);
        imWhiteBoard = showMenuView.findViewById(R.id.im_whiteboard);
        imAnnotation = showMenuView.findViewById(R.id.im_annotation);
        //设置CirCleLayout 中心View
        imShowingMenu = new AppCompatImageView(this);
        imShowingMenu.setId(R.id.circle_centerview);
        imShowingMenu.setImageResource(R.drawable.center_20);
        circleLayout.setCenterView(imShowingMenu);

        views = new ArrayList<>();
        views.add(imTask);
        views.add(imReturn);
        views.add(imWindows);
        views.add(imHome);
        views.add(imAnnotation);
        views.add(imWhiteBoard);

        hideMenuView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                //init rect touch
                hideMenuHalfSize = hideMenuView.getHeight() / 2;

                hideMenuView.getViewTreeObserver()
                        .removeOnGlobalLayoutListener(this);
            }
        });

        showMenuView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                showMenuHalfSize = showMenuView.getHeight() / 2;

                showMenuView.getViewTreeObserver()
                        .removeOnGlobalLayoutListener(this);
            }
        });
    }
 
源代码28 项目: MyBookshelf   文件: MainActivity.java
/**
 * 侧边栏按钮
 */
private void setUpNavigationView() {
    navigationView.setBackgroundColor(ThemeStore.backgroundColor(this));
    NavigationViewUtil.setItemIconColors(navigationView, getResources().getColor(R.color.tv_text_default), ThemeStore.accentColor(this));
    NavigationViewUtil.disableScrollbar(navigationView);
    @SuppressLint("InflateParams") View headerView = LayoutInflater.from(this).inflate(R.layout.navigation_header, null);
    AppCompatImageView imageView = headerView.findViewById(R.id.iv_read);
    imageView.setColorFilter(ThemeStore.accentColor(this));
    navigationView.addHeaderView(headerView);
    Menu drawerMenu = navigationView.getMenu();
    vwNightTheme = drawerMenu.findItem(R.id.action_theme).getActionView().findViewById(R.id.iv_theme_day_night);
    upThemeVw();
    vwNightTheme.setOnClickListener(view -> setNightTheme(!isNightTheme()));
    navigationView.setNavigationItemSelectedListener(menuItem -> {
        drawer.closeDrawer(GravityCompat.START, !MApplication.isEInkMode);
        switch (menuItem.getItemId()) {
            case R.id.action_book_source_manage:
                handler.postDelayed(() -> BookSourceActivity.startThis(this, requestSource), 200);
                break;
            case R.id.action_replace_rule:
                handler.postDelayed(() -> ReplaceRuleActivity.startThis(this, null), 200);
                break;
            case R.id.action_download:
                handler.postDelayed(() -> DownloadActivity.startThis(this), 200);
                break;
            case R.id.action_setting:
                handler.postDelayed(() -> SettingActivity.startThis(this), 200);
                break;
            case R.id.action_about:
                handler.postDelayed(() -> AboutActivity.startThis(this), 200);
                break;
            case R.id.action_donate:
                handler.postDelayed(() -> DonateActivity.startThis(this), 200);
                break;
            case R.id.action_backup:
                handler.postDelayed(() -> BackupRestoreUi.INSTANCE.backup(this), 200);
                break;
            case R.id.action_restore:
                handler.postDelayed(() -> BackupRestoreUi.INSTANCE.restore(this), 200);
                break;
            case R.id.action_theme:
                handler.postDelayed(() -> ThemeSettingActivity.startThis(this), 200);
                break;
        }
        return true;
    });
}
 
源代码29 项目: GetApk   文件: EmptyDelegate.java
public EmptyViewHolder(View itemView) {
    super(itemView);
    mEmptyImg = (AppCompatImageView) itemView.findViewById(R.id.empty_img);
    mTitleTV = (AppCompatTextView) itemView.findViewById(R.id.title_tv);
    mEmptyTV = (AppCompatTextView) itemView.findViewById(R.id.empty_tv);
}
 
源代码30 项目: HaoReader   文件: AppCompat.java
public static void useCustomIconForSearchView(SearchView searchView, String hint, boolean showSearchHintIcon, boolean showBg) {
    final int normalColor = searchView.getResources().getColor(R.color.colorBarText);
    AppCompatImageView search = searchView.findViewById(androidx.appcompat.R.id.search_button);
    search.setImageResource(R.drawable.ic_search_large_black_24dp);
    setTint(search, normalColor);

    SearchView.SearchAutoComplete searchText = searchView.findViewById(R.id.search_src_text);
    searchText.setTextSize(14f);
    searchText.setPaddingRelative(searchText.getPaddingLeft(), 0, 0, 0);

    final int textSize = Math.round(searchText.getTextSize() * DRAWABLE_SCALE);
    Drawable searchIcon = searchText.getResources().getDrawable(R.drawable.ic_search_black_24dp);
    searchIcon.setBounds(0, 0, textSize, textSize);
    setTint(searchIcon, normalColor);
    searchText.setCompoundDrawablesRelative(searchIcon, null, null, null);
    searchText.setCompoundDrawablePadding(DensityUtil.dp2px(searchText.getContext(), 5));
    searchText.setIncludeFontPadding(false);

    AppCompatImageView close = searchView.findViewById(R.id.search_close_btn);
    close.setImageResource(R.drawable.ic_close_black_24dp);
    setTint(close, normalColor);

    LinearLayout plate = searchView.findViewById(R.id.search_plate);
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) plate.getLayoutParams();
    params.topMargin = DensityUtil.dp2px(plate.getContext(), 6);
    params.bottomMargin = params.topMargin;
    plate.setLayoutParams(params);

    View editFrame = searchView.findViewById(R.id.search_edit_frame);
    params = (LinearLayout.LayoutParams) editFrame.getLayoutParams();
    params.leftMargin = DensityUtil.dp2px(editFrame.getContext(), 4);
    editFrame.setLayoutParams(params);

    int padding = DensityUtil.dp2px(plate.getContext(), 6);
    plate.setPaddingRelative(padding, 0, padding, 0);

    if (showBg) {
        Drawable bag = searchView.getResources().getDrawable(R.drawable.bg_search_field);
        androidx.core.view.ViewCompat.setBackground(plate, bag);
    } else {
        androidx.core.view.ViewCompat.setBackground(plate, null);
    }

    setQueryHintForSearchText(searchText, hint, showSearchHintIcon);
}