當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。