本文整理了Java中android.widget.TextView.setCompoundDrawablePadding()
方法的一些代码示例,展示了TextView.setCompoundDrawablePadding()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.setCompoundDrawablePadding()
方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:setCompoundDrawablePadding
暂无
代码示例来源:origin: lygttpod/SuperTextView
/**
* 设置textView的drawable
*
* @param textView 对象
* @param drawableLeft 左边图标
* @param drawableTop 上边图标
* @param drawableRight 右边图标
* @param drawableBottom 下边图标
* @param drawablePadding 图标距离文字的间距
*/
public void setDrawable(TextView textView, Drawable drawableLeft, Drawable drawableTop, Drawable drawableRight, Drawable drawableBottom, int drawablePadding) {
textView.setCompoundDrawablesWithIntrinsicBounds(drawableLeft, drawableTop, drawableRight, drawableBottom);
textView.setCompoundDrawablePadding(drawablePadding);
}
代码示例来源:origin: lygttpod/SuperTextView
/**
* 设置textView的drawable
*
* @param textView 对象
* @param drawableLeft 左边图标
* @param drawableRight 右边图标
* @param drawablePadding 图标距离文字的间距
*/
public void setDefaultDrawable(TextView textView, Drawable drawableLeft, Drawable drawableRight, int drawablePadding, int drawableWidth, int drawableHeight) {
if (drawableLeft != null || drawableRight != null) {
textView.setVisibility(VISIBLE);
}
//可以指定drawable的宽高
if (drawableWidth != -1 && drawableHeight != -1) {
if (drawableLeft != null) {
drawableLeft.setBounds(0, 0, drawableWidth, drawableHeight);
}
if (drawableRight != null) {
drawableRight.setBounds(0, 0, drawableWidth, drawableHeight);
}
textView.setCompoundDrawables(drawableLeft, null, drawableRight, null);
} else {
textView.setCompoundDrawablesWithIntrinsicBounds(drawableLeft, null, drawableRight, null);
}
textView.setCompoundDrawablePadding(drawablePadding);
}
代码示例来源:origin: stackoverflow.com
tv.setCompoundDrawablePadding(dp5);
代码示例来源:origin: stackoverflow.com
textView.setCompoundDrawablesWithIntrinsicBounds(images.get(position), 0, 0, 0);
textView.setCompoundDrawablePadding(
(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, getContext().getResources().getDisplayMetrics()));
return view;
代码示例来源:origin: alexvasilkov/GestureViews
@Override
public void onBindViewHolder(ViewHolder viewHolder, int position) {
viewHolder.info = list.get(position);
viewHolder.text.setText(viewHolder.info.loadLabel(getPackageManager()));
// Setting tinted example icon
Context context = ExamplesActivity.this;
Drawable icon = DrawableCompat.wrap(viewHolder.info.loadIcon(getPackageManager()));
DrawableCompat.setTint(icon, ContextCompat.getColor(context, R.color.primary));
int padding = getResources().getDimensionPixelSize(R.dimen.example_icon_padding);
viewHolder.text.setCompoundDrawablePadding(padding);
viewHolder.text.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
}
代码示例来源:origin: stackoverflow.com
mTitle.setBackgroundColor(BLUE);
mTitle.setPadding(MARGIN + PADDING, MARGIN, MARGIN, MARGIN);
mTitle.setCompoundDrawablePadding(MARGIN + PADDING);
mTitle.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
mContent.addView(mTitle);
代码示例来源:origin: rey5137/material
v.setCompoundDrawablePadding(a.getDimensionPixelSize(attr, 0));
代码示例来源:origin: stackoverflow.com
Toast toast = Toast.makeText(this, "I am custom Toast!", Toast.LENGTH_LONG);
View toastView = toast.getView(); //This'll return the default View of the Toast.
/* And now you can get the TextView of the default View of the Toast. */
TextView toastMessage = (TextView) toastView.findViewById(android.R.id.message);
toastMessage.setTextSize(25);
toastMessage.setTextColor(Color.RED);
toastMessage.setCompoundDrawablesWithIntrinsicBounds(R.mipmap.ic_fly, 0, 0, 0);
toastMessage.setGravity(Gravity.CENTER);
toastMessage.setCompoundDrawablePadding(16);
toastView.setBackgroundColor(Color.CYAN);
toast.show();
代码示例来源:origin: multidots/android-app-common-tasks
text.setPadding(18, 18, 18, 18);
text.setTextColor(Color.WHITE);
text.setCompoundDrawablePadding(20);
text.setGravity(Gravity.CENTER_VERTICAL);
代码示例来源:origin: multidots/android-app-common-tasks
text.setPadding(18, 18, 18, 18);
text.setTextColor(Color.WHITE);
text.setCompoundDrawablePadding(20);
text.setGravity(Gravity.CENTER_VERTICAL);
代码示例来源:origin: multidots/android-app-common-tasks
text.setPadding(14, 7, 7, 7);
text.setTextColor(Color.BLACK);
text.setCompoundDrawablePadding(10);
text.setGravity(Gravity.CENTER_VERTICAL);
代码示例来源:origin: multidots/android-app-common-tasks
text.setPadding(14, 7, 7, 7);
text.setTextColor(Color.BLACK);
text.setCompoundDrawablePadding(10);
text.setGravity(Gravity.CENTER_VERTICAL);
代码示例来源:origin: multidots/android-app-common-tasks
/**
* Sets title and icon of provider
*/
private void setUpTitle() {
requestWindowFeature(Window.FEATURE_NO_TITLE);
mTitle = new TextView(getContext());
int res = getContext().getResources().getIdentifier(mProviderName.toString(), "drawable",
getContext().getPackageName());
Drawable icon = getContext().getResources().getDrawable(res);
String sb = mProviderName.toString().substring(0, 1).toUpperCase(Locale.getDefault()) +
mProviderName.toString().substring(1, mProviderName.toString().length());
mTitle.setText(sb);
mTitle.setGravity(Gravity.CENTER_VERTICAL);
mTitle.setTextColor(Color.WHITE);
mTitle.setTypeface(Typeface.DEFAULT_BOLD);
mTitle.setBackgroundColor(BLUE);
mTitle.setPadding(MARGIN + PADDING, MARGIN, MARGIN, MARGIN);
mTitle.setCompoundDrawablePadding(MARGIN + PADDING);
mTitle.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
if (!titleStatus)
mContent.addView(mTitle);
}
代码示例来源:origin: multidots/android-app-common-tasks
/**
* Sets title and icon of provider
*/
private void setUpTitle() {
requestWindowFeature(Window.FEATURE_NO_TITLE);
mTitle = new TextView(getContext());
int res = getContext().getResources().getIdentifier(mProviderName.toString(), "drawable",
getContext().getPackageName());
Drawable icon = getContext().getResources().getDrawable(res);
String sb = mProviderName.toString().substring(0, 1).toUpperCase(Locale.getDefault()) +
mProviderName.toString().substring(1, mProviderName.toString().length());
mTitle.setText(sb);
mTitle.setGravity(Gravity.CENTER_VERTICAL);
mTitle.setTextColor(Color.WHITE);
mTitle.setTypeface(Typeface.DEFAULT_BOLD);
mTitle.setBackgroundColor(BLUE);
mTitle.setPadding(MARGIN + PADDING, MARGIN, MARGIN, MARGIN);
mTitle.setCompoundDrawablePadding(MARGIN + PADDING);
mTitle.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
if (!titleStatus)
mContent.addView(mTitle);
}
代码示例来源:origin: GeekGhost/Ghost
public static void setIconDrawable(Context mContext, TextView view, IIcon icon, int size, int padding) {
view.setCompoundDrawablesWithIntrinsicBounds(new IconicsDrawable(mContext)
.icon(icon)
.color(Color.WHITE)
.sizeDp(size),
null, null, null);
view.setCompoundDrawablePadding(ScreenUtil.dip2px(mContext, padding));
}
}
代码示例来源:origin: dongjunkun/GanK
private void setIconDrawable(TextView view, IIcon icon) {
view.setCompoundDrawablesWithIntrinsicBounds(new IconicsDrawable(this)
.icon(icon)
.color(Color.WHITE)
.sizeDp(16),
null, null, null);
view.setCompoundDrawablePadding(DimenUtils.dp2px(this, 10));
}
代码示例来源:origin: flipkart-incubator/proteus
@Override
public void setDimension(T view, float dimension) {
view.setCompoundDrawablePadding((int) dimension);
}
});
代码示例来源:origin: dongjunkun/GanK
private void setIconDrawable(TextView view, IIcon icon) {
view.setCompoundDrawablesWithIntrinsicBounds(new IconicsDrawable(getActivity())
.icon(icon)
.color(ThemeUtils.getThemeColor(getActivity(), R.attr.colorPrimary))
.sizeDp(14),
null, null, null);
view.setCompoundDrawablePadding(DimenUtils.dp2px(getActivity(), 5));
}
代码示例来源:origin: Janseon/CardMenuView
public static void setTextDrawableTop(TextView txt, int padDip, int resId) {
txt.setCompoundDrawables(null, getTextDrawable(txt.getContext(), resId), null, null);
if (padDip >= 0) {
txt.setCompoundDrawablePadding(dp2Px(txt.getContext(), padDip));
}
}
代码示例来源:origin: stackoverflow.com
Toast toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
TextView tv = (TextView) toast.getView().findViewById(android.R.id.message);
if (null!=tv) {
tv.setCompoundDrawablesWithIntrinsicBounds(icon, 0, 0, 0);
tv.setCompoundDrawablePadding(context.getResources().getDimensionPixelSize(R.dimen.padding_toast));
内容来源于网络,如有侵权,请联系作者删除!