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


Java TextView.setBackgroundColor方法代码示例

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


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

示例1: VerticalRecyclerViewHolder

import android.widget.TextView; //导入方法依赖的package包/类
public VerticalRecyclerViewHolder(View view) {
    super(view);

    time = (TextView) view.findViewById(R.id.tv_timeline_time);
    header = (TextView) view.findViewById(R.id.tv_timeline_header);
    header.setVisibility(View.INVISIBLE);

    timelineindicator_container = (RelativeLayout) view.findViewById(R.id.container_timeline_indicator);
    timelineindicator_line = (TextView) view.findViewById(R.id.tv_timeline_indicator_line);

    /*apply configs*/
    time.setTextColor(Color.parseColor(TimeLineConfig.getTimelineHeaderTextColour()));
    time.setTextSize(TimeLineConfig.getTimelineHeaderSize());
    timelineindicator_line.setBackgroundColor(Color.parseColor(TimeLineConfig.getTimelineIndicatorLineColour()));
    timelineindicator_container.setBackgroundColor(Color.parseColor(TimeLineConfig.getTimelineIndicatorBackgroundColour()));

    recyclerView = (RecyclerView) view.findViewById(R.id.rv_horizontal_timeline);

    LinearLayoutManager recyclerViewLayoutManager = new LinearLayoutManager(context);
    recyclerView.setLayoutManager(recyclerViewLayoutManager);
    LinearLayoutManager horizontalLinearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
    recyclerView.setLayoutManager(horizontalLinearLayoutManager);
}
 
开发者ID:akshaykale,项目名称:Android-Timeline-View,代码行数:24,代码来源:VerticalRecyclerViewAdapter.java

示例2: createMenuItem

import android.widget.TextView; //导入方法依赖的package包/类
/**
 * 创建MenuItem
 */
private View createMenuItem(final String itemTitle) {
    final TextView menuItem = new TextView(mContext);
    LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    params.leftMargin = params.rightMargin = mMenuItemMargin;
    menuItem.setLayoutParams(params);

    menuItem.setTextSize(14);
    menuItem.setTextColor(mMenuItemTextColor);
    menuItem.setBackgroundColor(mContext.getResources().getColor(android.R.color.transparent));
    menuItem.setGravity(Gravity.CENTER);
    menuItem.setText(itemTitle);
    menuItem.setTag(itemTitle);

    return menuItem;
}
 
开发者ID:devilist,项目名称:AdvancedTextView,代码行数:19,代码来源:ActionMenu.java

示例3: makeTitleView

import android.widget.TextView; //导入方法依赖的package包/类
private TextView makeTitleView(Context context, Map<String, Object> options) {
    String text = getOption(options, KEY_TITLE, null);
    if (text == null) {
        return null;
    }
    TextView textView = new TextView(context);
    textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
    int padding = WXViewUtils.dip2px(12);
    textView.setPadding(padding, padding, padding, padding);
    textView.getPaint().setFakeBoldText(true);
    textView.setBackgroundColor(getColor(options, KEY_TITLE_BACKGROUND_COLOR, Color.TRANSPARENT));
    textView.setTextColor(getColor(options, KEY_TITLE_COLOR, Color.BLACK));
    textView.setText(text);
    return textView;
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:17,代码来源:WXPickersModule.java

示例4: updateTextAndColor

import android.widget.TextView; //导入方法依赖的package包/类
private void updateTextAndColor(TextView categoryView, int count, TextView countView, int[] colors) {

        categoryView.setBackgroundColor(colors[2]);
        categoryView.setTextColor(colors[3]);

        GradientDrawable countD = new GradientDrawable();
        countD.setColor(colors[0]);
        countD.setCornerRadius(countView.getHeight() / 2);
        countView.setBackground(countD);
        countView.setTextColor(colors[1]);

        int c = count;
        if (countView == mCountRecent) {
            int recent = activity.getResources().getInteger(R.integer.sheet_recent_count);
            c = count > recent ? recent : c;
        }
        countView.setText(String.valueOf(c));

    }
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:20,代码来源:MainSheetsController.java

示例5: createMaskTextView

import android.widget.TextView; //导入方法依赖的package包/类
private TextView createMaskTextView(Context context, String text, int textSize, int gravity) {
    TextView maskTextView = new TextView(context);
    maskTextView.setTextColor(Color.BLACK);
    maskTextView.setBackgroundColor(Color.WHITE);
    maskTextView.setGravity(gravity | Gravity.CENTER_HORIZONTAL);
    maskTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    maskTextView.setText(text);
    return maskTextView;
}
 
开发者ID:scwang90,项目名称:SmartRefreshLayout,代码行数:10,代码来源:FunGameHeader.java

示例6: update

import android.widget.TextView; //导入方法依赖的package包/类
private void update() {
    viewHolder.imageSwitch.setImageResource(dataHolder.images[select]);
    for (int i = 0; i < viewHolder.texts.length; i++) {
        TextView view = viewHolder.texts[i];
        if (i == select) {
            view.setTextColor(selectTC);
            view.setBackgroundColor(selectBC);
        } else {
            view.setTextColor(mainTC);
            view.setBackgroundColor(Color.TRANSPARENT);
        }
    }
}
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:14,代码来源:PlayThemeCustomActivity.java

示例7: updateUI

import android.widget.TextView; //导入方法依赖的package包/类
private void updateUI(State newState) {
  final TextView label = (TextView) findViewById(R.id.label);
  label.setBackgroundColor(getResources().getColor(android.R.color.background_light));
  label.setText("");
  if (newState.isRefreshing) {
    label.setText("↺");
  } else if (newState.error != null) {
    label.setText(newState.error);
  } else if (newState.color != State.INVALID_COLOR) {
    label.setBackgroundColor(newState.color);
  }
}
 
开发者ID:groupon,项目名称:grox,代码行数:13,代码来源:MainActivity.java

示例8: addTextView

import android.widget.TextView; //导入方法依赖的package包/类
/**
 * 向父容器中添加TextView
 *
 * @param text  TextView显示文字
 * @param color TextView的背景颜色,如:"#FADBCC"
 */
private void addTextView(Context context, String text, int color) {
    TextView textView = new TextView(context);
    textView.setBackgroundColor(color);
    textView.setText(text);
    textView.setTextColor(textColor);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    textView.setSingleLine();
    textView.setGravity(Gravity.CENTER);
    textView.setLayoutParams(new LayoutParams(0, LayoutParams.WRAP_CONTENT, 1.0F));
    this.addView(textView);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:IndicatorView.java

示例9: getView

import android.widget.TextView; //导入方法依赖的package包/类
@Override public View getView(int position, View convertView, ViewGroup parent) {
    TextView view = (TextView) super.getView(position, convertView, parent);
    view.setTextColor(Color.DKGRAY);
    view.setTag("" + position);
    Item item = getItem(position);
    if (item.type == Item.SECTION) {
        //view.setOnClickListener(PinnedSectionListActivity.this);
        view.setBackgroundColor(parent.getResources().getColor(COLORS[item.sectionPosition % COLORS.length]));
    }
    return view;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:PinnedSectionListActivity.java

示例10: onCreateViewHolder

import android.widget.TextView; //导入方法依赖的package包/类
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    TextView view = new TextView(getActivity());
    view.setGravity(Gravity.CENTER);
    view.setBackgroundColor(Color.argb(125, 255, 0, 0));
    MyViewHolder mViewHolder = new MyViewHolder(view);
    parent.addView(view);
    return mViewHolder;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:StaggeredGridFragment.java

示例11: setScreenElements

import android.widget.TextView; //导入方法依赖的package包/类
private void setScreenElements() {
    TextView header = (TextView) findViewById(R.id.header);
    TextView text = (TextView) findViewById(R.id.app_name);
    ImageView icon = (ImageView) findViewById(R.id.about_icon);

    header.setBackgroundColor(AppPreferences.get(this).getPrimaryColor());
    text.setText(String.format("%s %s", getResources().getString(R.string.app_name), OtherUtils.getAppVersionName(getApplicationContext())));
    if (AppPreferences.get(this).getTheme().equals("0")) {
        icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.grey_two));
    }
}
 
开发者ID:dkanada,项目名称:OpenAPK,代码行数:12,代码来源:AboutActivity.java

示例12: initView

import android.widget.TextView; //导入方法依赖的package包/类
private void initView() {
    LayoutInflater layoutInflater = getLayoutInflater();
    mListContainer = (HorizontalScrollViewEx2) findViewById(R.id.container);
    int screenWidth = MyUtil.getScreenMetrics(this).widthPixels;
    for (int i = 0; i < 3; i++) {
        ViewGroup layout = (ViewGroup) layoutInflater.inflate(R.layout.content_layout2, mListContainer, false);
        layout.getLayoutParams().width = screenWidth;
        TextView textView = (TextView) layout.findViewById(R.id.title);
        textView.setText("page " + (i + 1));
        textView.setBackgroundColor(Color.rgb(255 / (i + 1), 255 / (i + 1), 0));
        createList(layout);
        mListContainer.addView(layout);
    }
}
 
开发者ID:DysaniazzZ,项目名称:ArtOfAndroid,代码行数:15,代码来源:Demo2Activity.java

示例13: getColoredView

import android.widget.TextView; //导入方法依赖的package包/类
protected View getColoredView(int bgColor, String msg) {
    TextView tv = new TextView(this);
    tv.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    tv.setText(msg);
    tv.setBackgroundColor(bgColor);
    tv.setPadding(10, 10, 10, 10);
    tv.setTextColor(getContrastColor(bgColor));
    return tv;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:SampleParentActivity.java

示例14: initUnit

import android.widget.TextView; //导入方法依赖的package包/类
public void initUnit() {
    if (this.mUnits != null && this.mUnits.size() != 0 && this.currentUnit != null) {
        LayoutParams parms = new LayoutParams(-1, -2, 1.0f);
        this.ll_diet_unit.removeAllViews();
        this.unitTextViews.clear();
        for (int i = 0; i < this.mUnits.size(); i++) {
            TextView textView = new TextView(getContext());
            textView.setText(((Unit) this.mUnits.get(i)).unit_name);
            textView.setGravity(17);
            textView.setTextSize(18.0f);
            textView.setTextColor(getResources().getColor(R.color.color_light));
            textView.setBackgroundColor(getResources().getColor(R.color.color_divider));
            textView.setSingleLine(true);
            textView.setEllipsize(TruncateAt.END);
            textView.setId(i);
            textView.setOnClickListener(new UnitListener());
            if (TextUtils.equals(((Unit) this.mUnits.get(i)).unit_name, this.currentUnit
                    .unit_name)) {
                textView.setTextColor(-1);
                textView.setBackgroundColor(getResources().getColor(R.color.color_bg_number));
            }
            this.unitTextViews.add(textView);
            this.ll_diet_unit.addView(textView, parms);
        }
        if (this.mAmount < 0.0f) {
            this.mAmount = 100.0f;
        }
        this.mGram = Float.parseFloat(this.currentUnit.eat_weight) * this.mAmount;
        this.mCalory = this.mWeight * this.mGram;
        this.txt_value.setText(this.mAmount + "");
        swithTxt();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:34,代码来源:DietKeyboard.java

示例15: createTextView

import android.widget.TextView; //导入方法依赖的package包/类
private TextView createTextView() {
    TextView textView = new TextView(this);
    textView.setLayoutParams(new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    textView.setTextColor(Color.CYAN);
    textView.setTextSize(30f);
    textView.setBackgroundColor(Color.RED);
    textView.setText("tips view");
    return textView;
}
 
开发者ID:arjinmc,项目名称:Android-GuideView,代码行数:11,代码来源:MainActivity.java


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