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