本文整理了Java中android.widget.TextView.setCompoundDrawablesWithIntrinsicBounds()
方法的一些代码示例,展示了TextView.setCompoundDrawablesWithIntrinsicBounds()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.setCompoundDrawablesWithIntrinsicBounds()
方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:setCompoundDrawablesWithIntrinsicBounds
暂无
代码示例来源:origin: stackoverflow.com
TextView textView = (TextView) findViewById(R.id.myTxtView);
textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon, 0, 0, 0);
代码示例来源:origin: stackoverflow.com
TextView textView = (TextView)findViewById(R.id.myTxtView);
textView.setCompoundDrawablesWithIntrinsicBounds(
R.drawable.icon, //left
0, //top
0, //right
0);//bottom
代码示例来源:origin: Naoki2015/CircleDemo
public void setLeftImageResource(int resId) {
mLeftText.setCompoundDrawablesWithIntrinsicBounds(resId, 0, 0, 0);
}
代码示例来源:origin: stackoverflow.com
public void setupTabLayout(TabLayout tabLayout) {
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
tabLayout.setTabGravity(TabLayout.GRAVITY_CENTER);
tabLayout.setupWithViewPager(mViewpager);
TextView tab = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
tab.setText("Library");
tab.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_tabbar_library, 0, 0);
tabLayout.getTabAt(0).setCustomView(tab);
//..
}
代码示例来源:origin: dongjunkun/DropDownMenu
private void fillValue(int position, ViewHolder viewHolder) {
viewHolder.mText.setText(list.get(position));
if (checkItemPosition != -1) {
if (checkItemPosition == position) {
viewHolder.mText.setTextColor(context.getResources().getColor(R.color.drop_down_selected));
viewHolder.mText.setCompoundDrawablesWithIntrinsicBounds(null, null, context.getResources().getDrawable(R.mipmap.drop_down_checked), null);
} else {
viewHolder.mText.setTextColor(context.getResources().getColor(R.color.drop_down_unselected));
viewHolder.mText.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
}
}
}
代码示例来源:origin: aa112901/remusic
@Override
public void setCompoundDrawablesWithIntrinsicBounds(int left, int top, int right, int bottom) {
if (mCompoundDrawableHelper != null) {
mCompoundDrawableHelper.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
} else {
super.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
}
}
代码示例来源:origin: aa112901/remusic
@Override
public void setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom) {
super.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
if (mCompoundDrawableHelper != null) {
mCompoundDrawableHelper.setCompoundDrawablesWithIntrinsicBounds();
}
}
代码示例来源:origin: aa112901/remusic
/**
* Internal use
*/
private void setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom) {
if (skipNextApply()) return;
((TextView) mView).setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
}
代码示例来源: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: mttkay/ignition
private void setCompoundDrawable(Drawable drawable) {
DisplayMetrics metrics = new DisplayMetrics();
metrics = view.getContext().getResources().getDisplayMetrics();
if (drawable instanceof BitmapDrawable) {
// For some reason this must be set explicitly or otherwise the target density will be
// wrong.
((BitmapDrawable) drawable).setTargetDensity(metrics.densityDpi);
}
Drawable leftDrawable = left ? drawable : null;
Drawable topDrawable = top ? drawable : null;
Drawable rightDrawable = right ? drawable : null;
Drawable bottomDrawable = bottom ? drawable : null;
((TextView) view).setCompoundDrawablesWithIntrinsicBounds(leftDrawable, topDrawable,
rightDrawable, bottomDrawable);
}
}
代码示例来源:origin: hidroh/materialistic
public void reset() {
if (!mIsLocal) {
mRankTextView.setText(R.string.loading_text);
mScoreTextView.setText(R.string.loading_text);
mScoreTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
mBookmarked.setVisibility(INVISIBLE);
}
mTitleTextView.setText(getContext().getString(R.string.loading_text));
mPostedTextView.setText(R.string.loading_text);
mSourceTextView.setText(R.string.loading_text);
mSourceTextView.setCompoundDrawables(null, null, null, null);
mCommentButton.setVisibility(View.INVISIBLE);
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView row=
(TextView)super.getView(position, convertView, parent);
int icon=
restrictions.getBoolean(getItem(position))
? R.drawable.ic_true : R.drawable.ic_false;
row.setCompoundDrawablesWithIntrinsicBounds(0, 0, icon, 0);
return(row);
}
}
代码示例来源:origin: robolectric/robolectric
@Implementation
protected void setCompoundDrawablesWithIntrinsicBounds(int left, int top, int right, int bottom) {
this.compoundDrawablesWithIntrinsicBoundsLeft = left;
this.compoundDrawablesWithIntrinsicBoundsTop = top;
this.compoundDrawablesWithIntrinsicBoundsRight = right;
this.compoundDrawablesWithIntrinsicBoundsBottom = bottom;
directlyOn(realTextView, TextView.class).setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
}
代码示例来源:origin: dongjunkun/DropDownMenu
/**
* 关闭菜单
*/
public void closeMenu() {
if (current_tab_position != -1) {
((TextView) tabMenuView.getChildAt(current_tab_position)).setTextColor(textUnselectedColor);
((TextView) tabMenuView.getChildAt(current_tab_position)).setCompoundDrawablesWithIntrinsicBounds(null, null,
getResources().getDrawable(menuUnselectedIcon), null);
popupMenuViews.setVisibility(View.GONE);
popupMenuViews.setAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.dd_menu_out));
maskView.setVisibility(GONE);
maskView.setAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.dd_mask_out));
current_tab_position = -1;
}
}
代码示例来源:origin: hidroh/materialistic
private void changeToggleState(ToggleItemViewHolder holder, Item item, boolean expanded) {
holder.mToggle.setText(mContext.getResources()
.getQuantityString(R.plurals.comments_count, item.getKidCount(), item.getKidCount()));
holder.mToggle.setCompoundDrawablesWithIntrinsicBounds(0, 0, expanded ?
R.drawable.ic_expand_less_white_24dp : R.drawable.ic_expand_more_white_24dp, 0);
}
代码示例来源: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: facebook/facebook-android-sdk
private void setCurrentRequestState(RequestState currentRequestState) {
this.currentRequestState = currentRequestState;
confirmationCode.setText(currentRequestState.getUserCode());
final Bitmap bitmap =
DeviceRequestsHelper.generateQRCode(currentRequestState.getAuthorizationUri());
final BitmapDrawable qrCode = new BitmapDrawable(getResources(), bitmap);
instructions.setCompoundDrawablesWithIntrinsicBounds(null, qrCode, null, null);
confirmationCode.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
if (!isRetry) {
if (DeviceRequestsHelper.startAdvertisementService(currentRequestState.getUserCode())) {
final AppEventsLogger logger = AppEventsLogger.newLogger(getContext());
logger.logSdkEvent(AnalyticsEvents.EVENT_SMART_LOGIN_SERVICE, null, null);
}
}
// If we polled within the last interval schedule a poll else start a poll.
if (currentRequestState.withinLastRefreshWindow()) {
schedulePoll();
} else {
poll();
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void setCompoundDrawablesWithIntrinsicBounds_setsValues() {
textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.l0_red, R.drawable.l1_orange, R.drawable.l2_yellow, R.drawable.l3_green);
assertThat(shadowOf(textView).getCompoundDrawablesWithIntrinsicBoundsLeft()).isEqualTo(R.drawable.l0_red);
assertThat(shadowOf(textView).getCompoundDrawablesWithIntrinsicBoundsTop()).isEqualTo(R.drawable.l1_orange);
assertThat(shadowOf(textView).getCompoundDrawablesWithIntrinsicBoundsRight()).isEqualTo(R.drawable.l2_yellow);
assertThat(shadowOf(textView).getCompoundDrawablesWithIntrinsicBoundsBottom()).isEqualTo(R.drawable.l3_green);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testSetCompountDrawablesWithIntrinsicBounds_int_shouldNotCreateDrawablesForZero() throws Exception {
textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
assertNull(textView.getCompoundDrawables()[0]);
assertNull(textView.getCompoundDrawables()[1]);
assertNull(textView.getCompoundDrawables()[2]);
assertNull(textView.getCompoundDrawables()[3]);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testSetCompountDrawablesWithIntrinsicBounds_int_shouldCreateDrawablesWithResourceIds() throws Exception {
textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.an_image, R.drawable.an_other_image, R.drawable.third_image, R.drawable.fourth_image);
assertEquals(R.drawable.an_image, shadowOf(textView.getCompoundDrawables()[0]).getCreatedFromResId());
assertEquals(R.drawable.an_other_image, shadowOf(textView.getCompoundDrawables()[1]).getCreatedFromResId());
assertEquals(R.drawable.third_image, shadowOf(textView.getCompoundDrawables()[2]).getCreatedFromResId());
assertEquals(R.drawable.fourth_image, shadowOf(textView.getCompoundDrawables()[3]).getCreatedFromResId());
}
内容来源于网络,如有侵权,请联系作者删除!