当前位置: 首页>>代码示例>>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;未经允许,请勿转载。