當前位置: 首頁>>代碼示例>>Java>>正文


Java TextView.setBackgroundDrawable方法代碼示例

本文整理匯總了Java中android.widget.TextView.setBackgroundDrawable方法的典型用法代碼示例。如果您正苦於以下問題:Java TextView.setBackgroundDrawable方法的具體用法?Java TextView.setBackgroundDrawable怎麽用?Java TextView.setBackgroundDrawable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.TextView的用法示例。


在下文中一共展示了TextView.setBackgroundDrawable方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addTextTab

import android.widget.TextView; //導入方法依賴的package包/類
public void addTextTab(final int position, String title) {
    TextView tab = new TextView(getContext());
    tab.setText(title);
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tab.setTextColor(0xffffffff);
    tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    tab.setTypeface(Typeface.DEFAULT_BOLD);
    tab.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR, false));

    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            didSelectTab(position);
        }
    });
    addView(tab);
    LayoutParams layoutParams = (LayoutParams)tab.getLayoutParams();
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.width = 0;
    layoutParams.weight = 50;
    tab.setLayoutParams(layoutParams);

    tabCount++;
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:27,代碼來源:SlidingTabView.java

示例2: setCurrentItemSelect

import android.widget.TextView; //導入方法依賴的package包/類
public void setCurrentItemSelect(View view) {

        drawBackground();
        TextView tv = (TextView) view;
        tv.setTextColor(tabSelectTextColor);
        int tag = (int) tv.getTag();
        switch (tag) {
            case TAG_LEFT_VIEW:
                tv.setBackgroundDrawable(mLeftSelectDrawable);
                break;
            case TAG_NONE_VIEW:
                tv.setBackgroundDrawable(mSimpleSelectDrawable);
                break;
            case TAG_RIGHT_VIEW:
                tv.setBackgroundDrawable(mRightSelectDrawable);
                break;
        }

        switchViewPager(tag);

    }
 
開發者ID:guzhigang001,項目名稱:Bailan,代碼行數:22,代碼來源:SubTabNavigator.java

示例3: createTextView

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * 創建 TextView 並返回
 *
 * @return {@link TextView}
 */
private TextView createTextView()
{
    TextView tv = new TextView(context);
    tv.setGravity(Gravity.CENTER);
    tv.setTextColor(textColor);
    tv.setTextSize(textSize);
    tv.setMaxLines(1);
    tv.setEllipsize(TextUtils.TruncateAt.END);
    tv.setBackgroundDrawable(createFrameDrawableBg());
    return tv;
}
 
開發者ID:Ayvytr,項目名稱:EasyAndroid,代碼行數:17,代碼來源:NewAuthEditText.java

示例4: getTextView

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * 獲得一個設置好屬性的TextView
 *
 * @param msg
 * @return
 */
public TextView getTextView(String msg) {
    TextView tv = new TextView(mContext);
    tv.setLayoutParams(lp_WW);
    tv.setText(msg);
    tv.setTextColor(defaultTextColor);
    Drawable background = null;
    if (defaultBackgroundResid != null) {
        background = mContext.getResources().getDrawable(defaultBackgroundResid);
    } else {
        background = defaultBackgroundColor;
    }
    if (currentapiVersion > 10) tv.setBackground(background);
    else tv.setBackgroundDrawable(background);
    tv.setPadding(5, 5, 5, 5);
    tv.setGravity(Gravity.CENTER);
    return tv;
}
 
開發者ID:jeasinlee,項目名稱:AndroidBasicLibs,代碼行數:24,代碼來源:DrawerToast.java

示例5: createTag

import android.widget.TextView; //導入方法依賴的package包/類
private void createTag(String s, @ColorInt int tintColor) {
    TextView textView = new TextView(getContext());
    LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lp.rightMargin = dp2px(4);
    textView.setLayoutParams(lp);
    textView.setTextSize(9);
    Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.shape_round_stroke_bg_tag);
    DrawableCompat.setTint(drawable, tintColor);
    if (Build.VERSION.SDK_INT > 15)
        textView.setBackground(drawable);
    else
        textView.setBackgroundDrawable(drawable);
    textView.setPadding(dp2px(2), 0, dp2px(2), 0);
    textView.setText(s);

    addView(textView);
}
 
開發者ID:woxingxiao,項目名稱:GracefulMovies,代碼行數:18,代碼來源:TagGroup.java

示例6: select

import android.widget.TextView; //導入方法依賴的package包/類
public void select(int dayOfOrder) {
    this.selected = dayOfOrder;
    resetSelect();
    if (this.mSelectListener != null) {
        this.mSelectListener.onSelect(dayOfOrder);
    }
    TextView tv = (TextView) this.tvList.get(dayOfOrder);
    tv.setTextColor(getResources().getColor(R.color.ju));
    ShapeDrawable oval = new ShapeDrawable(new OvalShape());
    if (dayOfOrder == this.orderOfToday) {
        oval.getPaint().setColor(getResources().getColor(R.color.he));
    } else {
        oval.getPaint().setColor(getResources().getColor(R.color.hb));
    }
    tv.setBackgroundDrawable(oval);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:17,代碼來源:WeekView.java

示例7: setDefaultNumKey

import android.widget.TextView; //導入方法依賴的package包/類
private void setDefaultNumKey(TextView view, int key) {
    view.setText(String.valueOf(key));
    if (null != mNumBgDrawSelector) {
        Drawable tempNumBg = mNumBgDrawSelector.getConstantState()
                .newDrawable();
        view.setBackgroundDrawable(tempNumBg);
    } else {
        ColorDrawable normal = new ColorDrawable(Color.WHITE);
        ColorDrawable press = new ColorDrawable(Color.GRAY);
        view.setBackgroundDrawable(getDrawableSeletor(normal, press));
    }
}
 
開發者ID:VigorousLiang,項目名稱:PWEditText-SafeKeyboard,代碼行數:13,代碼來源:SafetyKeyboard.java

示例8: setFrameColor

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * 設置 TextView邊框顏色
 *
 * @param frameColor 邊框顏色
 */
public void setFrameColor(@ColorInt int frameColor)
{
    this.frameColor = frameColor;
    for(TextView tv : textViewList)
    {
        tv.setBackgroundDrawable(createFrameDrawableBg());
    }
}
 
開發者ID:Ayvytr,項目名稱:EasyAndroid,代碼行數:14,代碼來源:NewAuthEditText.java

示例9: init

import android.widget.TextView; //導入方法依賴的package包/類
private void init(final Context context) {


        for (ViewDumper.ViewItem item : list) {
            TextView tv = new TextView(context);
            tv.setTag(item);
            //紅框
            GradientDrawable redBounds = new GradientDrawable();
            redBounds.setStroke(2, Color.RED);
            redBounds.setColor(Color.TRANSPARENT);
            tv.setBackgroundDrawable(redBounds);
            AbsoluteLayout.LayoutParams layoutParams = new AbsoluteLayout.LayoutParams(item.wh.x, item.wh.y, item.bounds.x, item.bounds.y - getStatusBarHeight());
            absoluteLayout.addView(tv, layoutParams);
        }
    }
 
開發者ID:w568w,項目名稱:fuckView,代碼行數:16,代碼來源:FullScreenPopupWindow.java

示例10: refreshDrawable

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * refresh's background drawable
 */
private void refreshDrawable() {
    if (isWeakReferenceValid()) {
        TextView textView = getTextView().get();
        textView.setBackgroundDrawable(getBadgeDrawable(textView.getContext()));
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:TextBadgeItem.java

示例11: getDefaultTextView

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * 獲取返回默認的 TextView
 */
public TextView getDefaultTextView()
{
    TextView tv = new TextView(context);
    tv.setGravity(Gravity.CENTER);
    tv.setTextSize(textSize);
    tv.setTextColor(textColor);
    tv.setBackgroundDrawable(frameDrawable);

    return tv;
}
 
開發者ID:Ayvytr,項目名稱:EasyAndroid,代碼行數:14,代碼來源:AuthEditText.java

示例12: setFrameWidth

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * 設置 TextView邊框寬度,單位為像素
 *
 * @param frameWidth 邊框寬度
 */
public void setFrameWidth(int frameWidth)
{
    this.frameWidth = frameWidth;
    for(int i = 1; i < textViewList.size(); i++)
    {
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) textViewList.get(i).getLayoutParams();
        lp.leftMargin = -frameWidth;
    }
    for(TextView tv : textViewList)
    {
        tv.setBackgroundDrawable(createFrameDrawableBg());
    }
}
 
開發者ID:Ayvytr,項目名稱:EasyAndroid,代碼行數:19,代碼來源:NewAuthEditText.java

示例13: getView

import android.widget.TextView; //導入方法依賴的package包/類
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(this.context).inflate(R.layout.jm, parent, false);
    }
    final ScaleIndex itemData = (ScaleIndex) getItem(position);
    TextView amount = (TextView) convertView.findViewById(R.id.tv_amount);
    TextView level = (TextView) convertView.findViewById(R.id.tv_level);
    ((TextView) convertView.findViewById(R.id.tv_name)).setText(itemData.getName());
    amount.setText(itemData.getValueWithUnit());
    GradientDrawable drawable = new GradientDrawable();
    drawable.setColor(ViewCompat.MEASURED_SIZE_MASK);
    drawable.setCornerRadius(this.outerR[0]);
    drawable.setStroke(1, itemData.getColor());
    level.setBackgroundDrawable(drawable);
    level.setTextColor(itemData.getColor());
    level.setText(itemData.getLevelName());
    if (itemData instanceof FakeIndex) {
        convertView.setOnClickListener(null);
    } else {
        convertView.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                WeightDetailAdapter.this.mFragment.getDialog().getWindow()
                        .setWindowAnimations(R.style.df);
                ScaleIndexActivity.startActivity(WeightDetailAdapter.this.context,
                        WeightDetailAdapter.this.mRecord, itemData.getName());
            }
        });
    }
    return convertView;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:31,代碼來源:WeightDetailAdapter.java

示例14: setBackground

import android.widget.TextView; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
public static void setBackground(Drawable imagebakground,TextView view){
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    	view.setBackground(imagebakground);
    } else {
    	view.setBackgroundDrawable(imagebakground);
    }
}
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:10,代碼來源:VersionUtils.java

示例15: addMenuView

import android.widget.TextView; //導入方法依賴的package包/類
private void addMenuView(Context context, ImageView iv, TextView tv, boolean show) {
        //SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
        //int cColor = themePrefs.getInt("chatsHeaderTabCounterColor", 0xffffffff);
        //int bgColor = themePrefs.getInt("chatsHeaderTabCounterBGColor", 0xffff0000);

        iv.setScaleType(ImageView.ScaleType.CENTER);
        //int size = themePrefs.getInt("chatsHeaderTabCounterSize", 11);
        //tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, size);
        tv.setGravity(Gravity.RIGHT);
        //tv.setTextColor(cColor);

        GradientDrawable shape = new GradientDrawable();
        shape.setShape(GradientDrawable.RECTANGLE);
        shape.setCornerRadius(AndroidUtilities.dp(32));
        //shape.setColor(bgColor);

        tv.setBackgroundDrawable(shape);
        //tv.setPadding(AndroidUtilities.dp(size > 10 ? size - 7 : 4), 0, AndroidUtilities.dp(size > 10 ? size - 7 : 4), 0);
        RelativeLayout layout = new RelativeLayout(context);
        layout.addView(iv, LayoutHelper.createRelative(50, LayoutHelper.MATCH_PARENT));
        layout.addView(tv, LayoutHelper.createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 0, 10, 5, 0, RelativeLayout.ALIGN_PARENT_RIGHT));
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) tv.getLayoutParams();
        params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
        tv.setLayoutParams(params);
        if (show) {
            menu.addView(layout, LayoutHelper.createLinear(50, LayoutHelper.MATCH_PARENT, 0));
        }

//        MenuCount(notifsCounter);

    }
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:32,代碼來源:DialogsActivity.java


注:本文中的android.widget.TextView.setBackgroundDrawable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。