List of usage examples for android.widget TextView setCompoundDrawables
public void setCompoundDrawables(@Nullable Drawable left, @Nullable Drawable top, @Nullable Drawable right, @Nullable Drawable bottom)
From source file:com.jun.elephant.ui.widget.VoteDialog.java
private void setDrawableTop(TextView textView, int resId) { Drawable drawable = ContextCompat.getDrawable(mContext, resId); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); textView.setCompoundDrawables(null, drawable, null, null); }
From source file:com.geekandroid.sdk.sample.TabManagerSampleFragment.java
public View getItemIndicator(String text, int resId) { View view = null;//from w ww. j ava2s . c o m if (inflater == null) { inflater = LayoutInflater.from(getContext()); } view = inflater.inflate(R.layout.item_main_tab, null); TextView textView = (TextView) view.findViewById(R.id.item_main_tab_view); textView.setText(text); Drawable drawable = ContextCompat.getDrawable(getContext(), resId); drawable.setBounds(0, 0, 60, 60); textView.setCompoundDrawablePadding(10); textView.setCompoundDrawables(null, drawable, null, null); return view; }
From source file:ecust.news.myWidgetTabPageIndicator.java
public void setCurrentItem(int position) { //// w ww . j a va2 s . c o m for (int i = 0; i < linearLayout.getChildCount(); i++) { TextView textView = (TextView) linearLayout.getChildAt(i); if (i != position) { textView.setTextColor(textViewUnfocusedColor); textView.setCompoundDrawables(null, null, null, null); } else { textView.setTextColor(textViewFocusedColor); //drawable textView.measure(0, 0); int w = textView.getMeasuredWidth() - textView.getPaddingLeft() - textView.getPaddingRight(); int h = Global.dimenConvert.dip2px(dp_FocusedLineHeight); Drawable drawable = new ColorDrawable(Color.WHITE); drawable.setBounds(0, 0, w, h); textView.setCompoundDrawables(null, null, null, drawable); } } //?textView?? int sum_width = 0; for (int i = 0; i < position; i++) { sum_width += linearLayout.getChildAt(i).getWidth(); } //? sum_width -= this.getWidth() / 2 - linearLayout.getChildAt(position).getWidth() / 2; // this.smoothScrollTo(sum_width, 0); }
From source file:com.pengfei.fastopen.adapter.SettingAdapter.java
@Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { SettingItem item = list.get(groupPosition); if (convertView == null) { convertView = LayoutInflater.from(context).inflate(R.layout.item_dialog_item, parent, false); }/*from www . j a v a 2s . c o m*/ TextView itemTv = (TextView) convertView.findViewById(R.id.tv_item); Drawable itemIcon = context.getResources().getDrawable(item.itemIconRes); itemIcon.setBounds(0, 0, 48, 40); itemTv.setCompoundDrawables(itemIcon, null, null, null); itemTv.setText(item.itemName); return convertView; }
From source file:org.videolan.myvlc.core.gui.NewSidebarAdapter.java
@Override public View getView(int position, View v, ViewGroup parent) { SidebarEntry sidebarEntry = lstEntrie.get(position); /* If view not created */ if (v == null) { v = mInflater.inflate(R.layout.sidebar_item, parent, false); }/* w w w . j a v a 2 s. c o m*/ TextView textView = (TextView) v; textView.setText(sidebarEntry.name); Drawable img = MyVLCApp.getAppResources().getDrawable(sidebarEntry.drawableID); if (img != null) { int dp_32 = Util.convertDpToPx(32); img.setBounds(0, 0, dp_32, dp_32); textView.setCompoundDrawables(img, null, null, null); } return v; }
From source file:com.geekandroid.sdk.base.BaseActivity.java
public void setDrawableLeft(TextView textView, int resId, int padding, int bounds) { Drawable drawable = getDrawable(textView, resId, padding, bounds); textView.setCompoundDrawables(drawable, null, null, null); }
From source file:com.geekandroid.sdk.base.BaseActivity.java
public void setDrawableRight(TextView textView, int resId, int padding, int bounds) { Drawable drawable = getDrawable(textView, resId, padding, bounds); textView.setCompoundDrawables(null, null, drawable, null); }
From source file:com.geekandroid.sdk.base.BaseActivity.java
public void setDrawableTop(TextView textView, int resId, int padding, int bounds) { Drawable drawable = getDrawable(textView, resId, padding, bounds); textView.setCompoundDrawables(null, drawable, null, null); }
From source file:com.geekandroid.sdk.base.BaseActivity.java
public void setDrawableBottom(TextView textView, int resId, int padding, int bounds) { Drawable drawable = getDrawable(textView, resId, padding, bounds); textView.setCompoundDrawables(null, null, null, drawable); }
From source file:com.justwayward.reader.ui.easyadapter.BookDiscussionAdapter.java
@Override public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) { return new BaseViewHolder<DiscussionList.PostsBean>(parent, R.layout.item_community_book_discussion_list) { @Override//from w w w . ja va 2 s. c o m public void setData(DiscussionList.PostsBean item) { if (!SettingManager.getInstance().isNoneCover()) { holder.setCircleImageUrl(R.id.ivBookCover, Constant.IMG_BASE_URL + item.author.avatar, R.drawable.avatar_default); } else { holder.setImageResource(R.id.ivBookCover, R.drawable.avatar_default); } holder.setText(R.id.tvBookTitle, item.author.nickname) .setText(R.id.tvBookType, String.format(mContext.getString(R.string.book_detail_user_lv), item.author.lv)) .setText(R.id.tvTitle, item.title).setText(R.id.tvHelpfulYes, item.commentCount + "") .setText(R.id.tvLikeCount, item.likeCount + ""); try { TextView textView = holder.getView(R.id.tvHelpfulYes); if (item.type.equals("vote")) { Drawable drawable = ContextCompat.getDrawable(mContext, R.drawable.ic_notif_vote); drawable.setBounds(0, 0, ScreenUtils.dpToPxInt(15), ScreenUtils.dpToPxInt(15)); textView.setCompoundDrawables(drawable, null, null, null); } else { Drawable drawable = ContextCompat.getDrawable(mContext, R.drawable.ic_notif_post); drawable.setBounds(0, 0, ScreenUtils.dpToPxInt(15), ScreenUtils.dpToPxInt(15)); textView.setCompoundDrawables(drawable, null, null, null); } if (TextUtils.equals(item.state, "hot")) { holder.setVisible(R.id.tvHot, true); holder.setVisible(R.id.tvTime, false); holder.setVisible(R.id.tvDistillate, false); } else if (TextUtils.equals(item.state, "distillate")) { holder.setVisible(R.id.tvDistillate, true); holder.setVisible(R.id.tvHot, false); holder.setVisible(R.id.tvTime, false); } else { holder.setVisible(R.id.tvTime, true); holder.setVisible(R.id.tvHot, false); holder.setVisible(R.id.tvDistillate, false); holder.setText(R.id.tvTime, FormatUtils.getDescriptionTimeFromDateString(item.created)); } } catch (Exception e) { LogUtils.e(e.toString()); } } }; }