当前位置: 首页>>代码示例>>Java>>正文


Java TextView.setCompoundDrawables方法代码示例

本文整理汇总了Java中android.widget.TextView.setCompoundDrawables方法的典型用法代码示例。如果您正苦于以下问题:Java TextView.setCompoundDrawables方法的具体用法?Java TextView.setCompoundDrawables怎么用?Java TextView.setCompoundDrawables使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.TextView的用法示例。


在下文中一共展示了TextView.setCompoundDrawables方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateSuccess

import android.widget.TextView; //导入方法依赖的package包/类
@Override
public void onCreateSuccess(boolean lastHeart, long sid, long aid, TextView tvAttitude) {
    AttitudeContainer.sHeartContainer.put(sid, aid);
    if (lastHeart) {
        AppToast.showToast("上次点过赞了");
    } else {
        String countStr = tvAttitude.getText().toString();
        if (TextUtils.isDigitsOnly(countStr)) {
            int count = Integer.parseInt(countStr) + 1;
            tvAttitude.setText(NumberFormatter.formatWBCount(count, 60000));
        }
    }
    Drawable[] compoundDrawables = tvAttitude.getCompoundDrawables();
    if (compoundDrawables[0] != null) {
        Drawable drawable = mActivity.getResources().getDrawable(R.drawable.ic_like_press);
        // 必须设置图片大小,否则不显示
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        tvAttitude.setCompoundDrawables(drawable, null, null, null);
    } else {
        tvAttitude.setTextColor(ContextCompat.getColor(mActivity, R.color.colorPrimary));
    }
}
 
开发者ID:liying2008,项目名称:Simpler,代码行数:23,代码来源:StatusDataSetter.java

示例2: showBigImg

import android.widget.TextView; //导入方法依赖的package包/类
private void showBigImg(BaseViewHolder helper, News item) {
    //中间大图布局,判断是否有视频
    TextView tvBottomRight = helper.getView(R.id.id_info_tv);
    if (item.has_video) {
        helper.setVisible(R.id.id_play_iv, true);//显示播放按钮
        tvBottomRight.setCompoundDrawables(null, null, null, null);//去除TextView左侧图标
        helper.setText(R.id.id_info_tv, item.video_duration + "");//设置时长
        GlideApp.with(mContext)
                .load(item.video_detail_info.detail_video_large_image.url)
                .into((ImageView) helper.getView(R.id.id_iv));
    } else {
        helper.setVisible(R.id.id_play_iv, false);//隐藏播放按钮
        tvBottomRight.setCompoundDrawables(ResouceUtil.getDrawable(R.drawable.icon_picture_group), null, null, null);//TextView增加左侧图标
        helper.setText(R.id.id_info_tv, item.gallary_image_count + " 图");//设置时长
        GlideApp.with(mContext).load(item.image_list.get(0).url.replace("list/300x196", "large")).centerCrop()
                .into((ImageView) helper.getView(R.id.id_iv));//中间图片使用image_list第一张
    }
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:19,代码来源:NewsListAdapter.java

示例3: layoutPunctuationsAndReturnStartIndexOfMoreSuggestions

import android.widget.TextView; //导入方法依赖的package包/类
private int layoutPunctuationsAndReturnStartIndexOfMoreSuggestions(
        final PunctuationSuggestions punctuationSuggestions, final ViewGroup stripView) {
    final int countInStrip = Math.min(punctuationSuggestions.size(), PUNCTUATIONS_IN_STRIP);
    for (int positionInStrip = 0; positionInStrip < countInStrip; positionInStrip++) {
        if (positionInStrip != 0) {
            // Add divider if this isn't the left most suggestion in suggestions strip.
            addDivider(stripView, mDividerViews.get(positionInStrip));
        }

        final TextView wordView = mWordViews.get(positionInStrip);
        final String punctuation = punctuationSuggestions.getLabel(positionInStrip);
        // {@link TextView#getTag()} is used to get the index in suggestedWords at
        // {@link SuggestionStripView#onClick(View)}.
        wordView.setTag(positionInStrip);
        wordView.setText(punctuation);
        wordView.setContentDescription(punctuation);
        wordView.setTextScaleX(1.0f);
        wordView.setCompoundDrawables(null, null, null, null);
        wordView.setTextColor(mColorAutoCorrect);
        stripView.addView(wordView);
        setLayoutWeight(wordView, 1.0f, mSuggestionsStripHeight);
    }
    mMoreSuggestionsAvailable = (punctuationSuggestions.size() > countInStrip);
    return countInStrip;
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:26,代码来源:SuggestionStripLayoutHelper.java

示例4: convert

import android.widget.TextView; //导入方法依赖的package包/类
@Override
public void convert(EasyLVHolder holder, int position, BookMixAToc.mixToc.Chapters chapters) {
    TextView tvTocItem = holder.getView(R.id.tvTocItem);
    tvTocItem.setText(chapters.title);
    Drawable drawable;
    if (currentChapter == position + 1) {
        tvTocItem.setTextColor(ContextCompat.getColor(mContext, R.color.light_red));
        drawable = ContextCompat.getDrawable(mContext, R.drawable.ic_toc_item_activated);
    } else if (isEpub || FileUtils.getChapterFile(bookId, position + 1).length() > 10) {
        tvTocItem.setTextColor(ContextCompat.getColor(mContext, R.color.light_black));
        drawable = ContextCompat.getDrawable(mContext, R.drawable.ic_toc_item_download);
    } else {
        tvTocItem.setTextColor(ContextCompat.getColor(mContext, R.color.light_black));
        drawable = ContextCompat.getDrawable(mContext, R.drawable.ic_toc_item_normal);
    }
    drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
    tvTocItem.setCompoundDrawables(drawable, null, null, null);
}
 
开发者ID:ynztlxdeai,项目名称:TextReader,代码行数:19,代码来源:TocListAdapter.java

示例5: resetLayout

import android.widget.TextView; //导入方法依赖的package包/类
void resetLayout() {
    mContent.removeAllViewsInLayout();

    // 在hotseat中显示进入所有应用列表的图标
    if (!FeatureFlags.NO_ALL_APPS_ICON) {
        // Add the Apps button
        Context context = getContext();
        int allAppsButtonRank = mLauncher.getDeviceProfile().inv.getAllAppsButtonRank();

        LayoutInflater inflater = LayoutInflater.from(context);
        TextView allAppsButton = (TextView)
                inflater.inflate(R.layout.all_apps_button, mContent, false);
        Drawable d = context.getResources().getDrawable(R.drawable.all_apps_button_icon);

        mLauncher.resizeIconDrawable(d);
        int scaleDownPx = getResources().getDimensionPixelSize(R.dimen.all_apps_button_scale_down);
        Rect bounds = d.getBounds();
        d.setBounds(bounds.left, bounds.top + scaleDownPx / 2, bounds.right - scaleDownPx,
                bounds.bottom - scaleDownPx / 2);
        allAppsButton.setCompoundDrawables(null, d, null, null);

        allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
        allAppsButton.setOnKeyListener(new HotseatIconKeyEventListener());
        if (mLauncher != null) {
            mLauncher.setAllAppsButton(allAppsButton);
            allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
            allAppsButton.setOnClickListener(mLauncher);
            allAppsButton.setOnLongClickListener(mLauncher);
            allAppsButton.setOnFocusChangeListener(mLauncher.mFocusHandler);
        }

        // Note: We do this to ensure that the hotseat is always laid out in the orientation of
        // the hotseat in order regardless of which orientation they were added
        int x = getCellXFromOrder(allAppsButtonRank);
        int y = getCellYFromOrder(allAppsButtonRank);
        CellLayout.LayoutParams lp = new CellLayout.LayoutParams(x, y, 1, 1);
        lp.canReorder = false;
        mContent.addViewToCellLayout(allAppsButton, -1, allAppsButton.getId(), lp, true);
    }
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:41,代码来源:Hotseat.java

示例6: setTextViewBottomImage

import android.widget.TextView; //导入方法依赖的package包/类
public ViewHolder setTextViewBottomImage(int viewId, Drawable resId)
{
    TextView view = getView(viewId);
    resId.setBounds(0, 0, resId.getMinimumWidth(), resId.getMinimumHeight());

     view.setCompoundDrawables(null,null,null,resId);
    return this;
}
 
开发者ID:MedicationReminder,项目名称:MedicationReminder,代码行数:9,代码来源:ViewHolder.java

示例7: setTitleTxt

import android.widget.TextView; //导入方法依赖的package包/类
private void setTitleTxt(BoxingConfig config) {
    TextView titleTxt = (TextView) findViewById(R.id.pick_album_txt);
    if (config.getMode() == BoxingConfig.Mode.VIDEO) {
        titleTxt.setText(R.string.boxing_video_title);
        titleTxt.setCompoundDrawables(null, null, null, null);
        return;
    }
    mPickerFragment.setTitleTxt(titleTxt);
}
 
开发者ID:devzwy,项目名称:NeiHanDuanZiTV,代码行数:10,代码来源:BoxingActivity.java

示例8: setCompoundIconLeftOrClear

import android.widget.TextView; //导入方法依赖的package包/类
public static void setCompoundIconLeftOrClear(TextView tv, IIcon icon, int size, int color) {
    if (icon == null) {
        tv.setCompoundDrawables(null, null, null, null);
    } else {
        tv.setCompoundDrawables(getCompoundIcon(icon, size, color), null, null, null);
    }
}
 
开发者ID:MFlisar,项目名称:RecyclerViewPreferences,代码行数:8,代码来源:Util.java

示例9: setLeftImage

import android.widget.TextView; //导入方法依赖的package包/类
/**
 * 设置左侧图片
 * @param textView
 * @param resId
 * @param padding
 */
public static void setLeftImage(TextView textView, int resId, float padding) {
    if (textView != null) {
        Drawable drawable = textView.getContext().getResources().getDrawable(resId);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        textView.setCompoundDrawablePadding(DensityUtils.dip2px(textView.getContext(), padding));
        textView.setCompoundDrawables(drawable, null, null, null);
    }
}
 
开发者ID:Break369,项目名称:MyLife,代码行数:15,代码来源:TextViewUtils.java

示例10: apply

import android.widget.TextView; //导入方法依赖的package包/类
@Override
public void apply(View view) {
    if (view == null) {
        return;
    }
    if (view instanceof TextView) {//button extends TextView
        TextView textView = (TextView) view;
        Drawable bg = AndroidSkin.getInstance().getSkinDrawable(
                attrValueTypeName, attrValueRefName, attrValueRefId);
        Drawable[] bound = {null, null, null, null};
        switch (type) {
            case DRAWABLE_LEFT:
                bound[0] = bg;
                break;
            case DRAWABLE_TOP:
                bound[1] = bg;
                break;
            case DRAWABLE_RIGHT:
                bound[2] = bg;
                break;
            case DRAWABLE_BOTTOM:
                bound[3] = bg;
                break;
        }
        //textView.setCompoundDrawablePadding(0);
        textView.setCompoundDrawables(null, null, null, null);
        /// 这一步必须要做,否则不会显示.
        if (bound[0] != null)
            bound[0].setBounds(0, 0, bound[0].getIntrinsicWidth(), bound[0].getIntrinsicHeight());
        if (bound[1] != null)
            bound[1].setBounds(0, 0, bound[1].getIntrinsicWidth(), bound[1].getIntrinsicHeight());
        if (bound[2] != null)
            bound[2].setBounds(0, 0, bound[2].getIntrinsicWidth(), bound[2].getIntrinsicHeight());
        if (bound[3] != null)
            bound[3].setBounds(0, 0, bound[3].getIntrinsicWidth(), bound[3].getIntrinsicHeight());

        textView.setCompoundDrawables(bound[0], bound[1], bound[2], bound[3]);
    }

}
 
开发者ID:MeetYouDevs,项目名称:Android-Skin,代码行数:41,代码来源:DrawableLRTBAttr.java

示例11: setBottomImage

import android.widget.TextView; //导入方法依赖的package包/类
/**
 * 设置底部图片
 * @param textView
 * @param drawable
 * @param padding
 */
public static void setBottomImage(TextView textView, Drawable drawable, float padding) {
    if (textView != null) {
        if (drawable != null) {
            drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        }
        textView.setCompoundDrawablePadding(DensityUtils.dip2px(textView.getContext(), padding));
        textView.setCompoundDrawables(null, null, null, drawable);
    }
}
 
开发者ID:Break369,项目名称:MyLife,代码行数:16,代码来源:TextViewUtils.java

示例12: changeCompoundDrawableSize

import android.widget.TextView; //导入方法依赖的package包/类
/**
 * 修改 textview 的drawable size
 * <p>
 *
 * @param textView   textview
 * @param where      上下左右    0-左  1-上  2-右  3- 下
 * @param expectedWh 宽高,单位 dp
 *                   </p>
 * @see TextView#getCompoundDrawables()
 */
public static void changeCompoundDrawableSize(TextView textView, int where, int expectedWh) {
    if (where < 0 || where > 3)
        return;
    Drawable[] drawables = textView.getCompoundDrawables();
    Drawable drawable = drawables[where];
    if (drawable == null)
        return;
    int wh = SizeUtils.dp2px(expectedWh);
    Rect rect = new Rect(0, 0, wh, wh);
    drawable.setBounds(rect);
    drawables[where] = drawable;
    textView.setCompoundDrawables(drawables[0], drawables[1], drawables[2], drawables[3]);
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:24,代码来源:CompoundDrawableUtil.java

示例13: setDrawleft

import android.widget.TextView; //导入方法依赖的package包/类
public void setDrawleft(TextView view, int id) {
    if (!isAdded()) return;
    Drawable drawable_n = getResources().getDrawable(id);
    drawable_n.setBounds(0, 0, drawable_n.getMinimumWidth(), drawable_n.getMinimumHeight());  //此为必须写的
    view.setCompoundDrawables(drawable_n, null, null, null);
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:7,代码来源:UseMsgFragment.java

示例14: bind

import android.widget.TextView; //导入方法依赖的package包/类
@Override
protected void bind(Tab item, TabItemView view, int position) {
    TextView tv = view.getTextView();
    setTextViewTypeface(tv, false);
    // custom view
    List<View> mCustomViews = item.getCustomViews();
    if (mCustomViews != null && mCustomViews.size() > 0) {
        view.setTag(R.id.qmui_view_can_not_cache_tag, true);
        for (View v : mCustomViews) {
            // 防止先 setCustomViews 然后再 updateTabText 时会重复添加 customView 导致 crash
            if (v.getParent() == null) {
                view.addView(v);
            }
        }
    }
    // gravity
    if (mMode == MODE_FIXED) {
        int gravity = item.getGravity();
        RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) tv.getLayoutParams();
        lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, (gravity & Gravity.LEFT) == Gravity.LEFT ? RelativeLayout.TRUE : 0);
        lp.addRule(RelativeLayout.CENTER_HORIZONTAL, (gravity & Gravity.CENTER) == Gravity.CENTER ? RelativeLayout.TRUE : 0);
        lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, (gravity & Gravity.RIGHT) == Gravity.RIGHT ? RelativeLayout.TRUE : 0);
        tv.setLayoutParams(lp);
    }

    tv.setText(item.getText());

    // icon
    if (item.getNormalIcon() == null) {
        tv.setCompoundDrawablePadding(0);
        tv.setCompoundDrawables(null, null, null, null);
    } else {
        Drawable drawable = item.getNormalIcon();
        if (drawable != null) {
            drawable = drawable.mutate();
            setDrawable(tv, drawable, getTabIconPosition(item));
            tv.setCompoundDrawablePadding(QMUIDisplayHelper.dp2px(getContext(), 4));
        } else {
            tv.setCompoundDrawables(null, null, null, null);
        }
    }
    int textSize = item.getTextSize();
    if (textSize == Tab.USE_TAB_SEGMENT) {
        textSize = mTabTextSize;
    }
    tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);

    if (position == mSelectedIndex) {
        if (mIndicatorView != null && getViews().size() > 1) {
            if (mIndicatorDrawable != null) {
                QMUIViewHelper.setBackgroundKeepingPadding(mIndicatorView, mIndicatorDrawable);
            } else {
                mIndicatorView.setBackgroundColor(getTabSelectedColor(item));
            }
        }
        changeTabColor(view.getTextView(), getTabSelectedColor(item), item, STATUS_SELECTED);
    } else {
        changeTabColor(view.getTextView(), getTabNormalColor(item), item, STATUS_NORMAL);
    }

    view.setTag(position);
    view.setOnClickListener(mTabOnClickListener);
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:64,代码来源:QMUITabSegment.java

示例15: setLeftDrawable

import android.widget.TextView; //导入方法依赖的package包/类
/**
 * 设置左边的drawable
 *
 * @param tv
 * @param drawable
 */
public static void setLeftDrawable(TextView tv, Drawable drawable) {
    tv.setCompoundDrawables(drawable, null, null, null);
}
 
开发者ID:snowwolf10285,项目名称:PicShow-zhaipin,代码行数:10,代码来源:DrawableProvider.java


注:本文中的android.widget.TextView.setCompoundDrawables方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。