本文整理汇总了Java中android.support.v7.widget.CardView.setCardBackgroundColor方法的典型用法代码示例。如果您正苦于以下问题:Java CardView.setCardBackgroundColor方法的具体用法?Java CardView.setCardBackgroundColor怎么用?Java CardView.setCardBackgroundColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.CardView
的用法示例。
在下文中一共展示了CardView.setCardBackgroundColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SetNewContents
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
private void SetNewContents(int key) {
if (!Changes(key).equals("null")) {
CardView.LayoutParams param = new CardView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
CardView card = new CardView(this);
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("DARK_THEME_KEY", false))
card.setCardBackgroundColor(ContextCompat.getColor(this, R.color.DarkcolorPrimary));
card.setCardElevation(5);
card.setLayoutParams(param);
card.setPadding(ConvertTopx(15), ConvertTopx(15), ConvertTopx(15), ConvertTopx(15));
card.setUseCompatPadding(true);
TextView changes = new TextView(this);
changes.setGravity(Gravity.CENTER);
changes.setPadding(ConvertTopx(5), ConvertTopx(5), ConvertTopx(5), ConvertTopx(5));
changes.setText(Changes(key));
changes.setTypeface(Typeface.MONOSPACE);
if (firebaseRemoteConfig.getBoolean("mark_red") && key == 0)
changes.setTextColor(Color.RED);
card.addView(changes);
layout.addView(card);
}
bar.setVisibility(View.GONE);
}
示例2: SetThisColorToCard
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
private void SetThisColorToCard(int id) {
//grab all 7 cards
CardView cardView1 = (CardView) findViewById(R.id.QA1);
CardView cardView2 = (CardView) findViewById(R.id.QA2);
CardView cardView3 = (CardView) findViewById(R.id.QA3);
CardView cardView5 = (CardView) findViewById(R.id.QA5);
CardView cardView8 = (CardView) findViewById(R.id.QA8);
CardView cardView9 = (CardView) findViewById(R.id.QA9);
CardView cardView10 = (CardView) findViewById(R.id.QA10);
//set the background color
cardView1.setCardBackgroundColor(id);
cardView2.setCardBackgroundColor(id);
cardView3.setCardBackgroundColor(id);
cardView5.setCardBackgroundColor(id);
cardView8.setCardBackgroundColor(id);
cardView9.setCardBackgroundColor(id);
cardView10.setCardBackgroundColor(id);
}
示例3: convert
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
protected void convert(BaseViewHolder holder, final Collection item) {
final CardView layout = holder.getView(R.id.item_layout);
final AppCompatTextView title = holder.getView(R.id.title_txt);
final AppCompatTextView count = holder.getView(R.id.count_txt);
title.setText(String.valueOf(item.title));
count.setText(count.getContext().getString(R.string.photos, String.valueOf(item.total_photos)));
final AppCompatImageView image = holder.getView(R.id.item_image);
Collection.CoverPhoto cp = item.cover_photo;
mFullRequest.load(getRegularSizeUrl(cp.urls.regular))
.thumbnail(mThumbRequest.load(cp.urls.thumb))
.into(image);
float finalHeight = displaymetrics.widthPixels / ((float) cp.width / (float) cp.height);
image.setMinimumHeight((int) finalHeight);
startSaturationAnimation(image.getContext(), image);
layout.setCardBackgroundColor(computeCardBackgroundColor(cp.color));
}
示例4: show
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
public void show(String text, int duration) {
toast = new Toast(Global.getContext());
LayoutInflater inflate = (LayoutInflater) Global.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflate.inflate(R.layout.view_toast, null);
TextView tv = ViewUtils.getView(view, R.id.tv_toast);
CardView cv = ViewUtils.getView(view, R.id.cv_group);
tv.setText(text);
if (background != -1) {
cv.setCardBackgroundColor(background);
}
if (textColor != -1) {
tv.setTextColor(textColor);
}
if(gravity != -1){
toast.setGravity(gravity, xOffset, yOffset);
}
toast.setView(view);
toast.setDuration(duration);
toast.show();
}
示例5: onCreateView
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
final Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.wallet_address_fragment, container, false);
currentAddressQrView = (ImageView) view.findViewById(R.id.bitcoin_address_qr);
final CardView currentAddressQrCardView = (CardView) view.findViewById(R.id.bitcoin_address_qr_card);
currentAddressQrCardView.setCardBackgroundColor(Color.WHITE);
currentAddressQrCardView.setPreventCornerOverlap(false);
currentAddressQrCardView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View v) {
handleShowQRCode();
}
});
return view;
}
示例6: updateStatus
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
private void updateStatus(CharSequence text, @ColorInt int color, Drawable icon) {
if (mViewHolder != null) {
CardView statusCard = (CardView) ((ViewGroup) mViewHolder.itemView).getChildAt(0);
TextView status = statusCard.findViewById(android.R.id.text1);
if (icon != null) {
icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
status.setCompoundDrawablesRelative(icon, null, null, null);
} else {
status.setCompoundDrawablesRelative(null, null, null, null);
}
status.setText(text);
statusCard.setCardBackgroundColor(color);
}
}
示例7: convert
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
protected void convert(BaseViewHolder holder, final Photos item) {
final CardView layout = holder.getView(R.id.photos_item_id);
final AppCompatImageView image = holder.getView(R.id.item_image);
mFullRequest.load(getRegularSizeUrl(item.urls, image.getContext()))
.thumbnail(mThumbRequest.load(item.urls.thumb))
.into(image);
float finalHeight = displaymetrics.widthPixels / ((float) item.width / (float) item.height);
image.setMinimumHeight((int) finalHeight);
startSaturationAnimation(image.getContext(), image);
layout.setCardBackgroundColor(computeCardBackgroundColor(item.color));
}
示例8: cardViewSetBackgroundColor
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
private void cardViewSetBackgroundColor(Point point, CardView cardView) {
switch (point.getColor()) {
case NO_CONTENT:
cardView.setCardBackgroundColor(mContext.getResources().getColor(R.color.carview_no_content));
break;
case BROWN:
cardView.setCardBackgroundColor(mContext.getResources().getColor(R.color.brown_500));
break;
case DEEP_ORANGE:
cardView.setCardBackgroundColor(mContext.getResources().getColor(R.color.deep_orange_900));
break;
case ORANGE:
cardView.setCardBackgroundColor(mContext.getResources().getColor(R.color.orange_900));
break;
case GREEN:
cardView.setCardBackgroundColor(mContext.getResources().getColor(R.color.green));
break;
case LIGHT_BLUE:
cardView.setCardBackgroundColor(mContext.getResources().getColor(R.color.light_blue_900));
break;
case RED:
cardView.setCardBackgroundColor(mContext.getResources().getColor(R.color.red_900));
break;
case PINK:
cardView.setCardBackgroundColor(mContext.getResources().getColor(R.color.pink_600));
break;
case PURPLE:
cardView.setCardBackgroundColor(mContext.getResources().getColor(R.color.purple_800));
break;
default:
cardView.setCardBackgroundColor(mContext.getResources().getColor(R.color.theme_color_level2));
break;
}
}
示例9: cardViewSetBackgroundColor
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
private void cardViewSetBackgroundColor(Point point, CardView cardView) {
switch (point.getColor()) {
case NO_CONTENT:
cardView.setCardBackgroundColor(mContext.getResources().getColor(R.color.carview_no_content));
break;
case BROWN:
cardView.setCardBackgroundColor(mContext.getResources().getColor(R.color.brown_500));
break;
case DEEP_ORANGE:
cardView.setCardBackgroundColor(mContext.getResources().getColor(R.color.deep_orange_900));
break;
case ORANGE:
cardView.setCardBackgroundColor(mContext.getResources().getColor(R.color.orange_900));
break;
case GREEN:
cardView.setCardBackgroundColor(mContext.getResources().getColor(R.color.green));
break;
case LIGHT_BLUE:
cardView.setCardBackgroundColor(mContext.getResources().getColor(R.color.light_blue_900));
break;
case RED:
cardView.setCardBackgroundColor(mContext.getResources().getColor(R.color.red_900));
break;
case PINK:
cardView.setCardBackgroundColor(mContext.getResources().getColor(R.color.pink_600));
break;
case PURPLE:
cardView.setCardBackgroundColor(mContext.getResources().getColor(R.color.purple_800));
break;
case DEFAULT:
cardView.setCardBackgroundColor(mContext.getResources().getColor(R.color.theme_color_level2));
break;
}
}
示例10: setColor
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
private void setColor(CardView card, TextView text, int color) {
if (Color.alpha(color) == 0) {
//color not found
card.setVisibility(View.GONE);
return;
}
card.setCardBackgroundColor(color);
text.setTextColor(getTextColor(text.getContext(), color));
String colorHex = String.format("#%06X", (0xFFFFFF & color));
text.setText(colorHex);
card.setTag(colorHex);
card.setOnClickListener(onClickListener);
}
示例11: onCreate
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.view_dialog_evaluacion_view);
//Set content
LinearLayout lExit = (LinearLayout) findViewById(R.id.llExitD);
TextView text = (TextView) findViewById(R.id.textD);
TextView title = (TextView) findViewById(R.id.titleD);
TextView subtitle = (TextView) findViewById(R.id.subtitleD);
TextView type = (TextView) findViewById(R.id.typeD);
TextView date = (TextView) findViewById(R.id.dateD);
CardView card = (CardView) findViewById(R.id.cardD);
title.setText(AppManager.capAfterSpace(Html.fromHtml(data.getName()).toString()));
card.setCardBackgroundColor(Color.parseColor(ColorHelper.getColor(AppManager.after(data.getType(), " ").charAt(0))));
type.setText(AppManager.capAfterSpace(data.getType()));
subtitle.setText(getContext().getString(R.string.evaluacion_published_in) + " " + AppManager.capAfterSpace(data.getSubject()));
String sdate = getContext().getString(R.string.evaluacion_from) + " " + DateFormat.format("dd", data.getStart()) + "/" + DateFormat.format("MM", data.getStart()) + "/" + (data.getStart().getYear() + 1900)
+ " " + getContext().getString(R.string.evaluacion_to) + " " + DateFormat.format("dd", data.getEnd()) + "/" + DateFormat.format("MM", data.getStart()) + "/" + (data.getEnd().getYear() + 1900);
date.setText(sdate);
text.setText(Html.fromHtml(data.getTable()));
lExit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EvaluacionViewDialog.super.onBackPressed();
}
});
}
示例12: refreshColor
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
public void refreshColor(){
CardView v = getCardContainer();
int rcolor = color;
int tcolor = color;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(v.getContext());
String theme = prefs.getString("theme","Light");
if(theme.equals("Auto")){
int hour = Calendar.getInstance(TimeZone.getDefault()).get(Calendar.HOUR_OF_DAY);
theme = "Dark";
if(hour>=5&&hour<17) theme="Light";
}
int bgColor = prefs.getInt("bgColor",Card.DEFAULT_COLOR);
if(theme.equals("Light")){
tcolor = COLORS.get("White");
setTints("#555555", 0xffffff);
}else if(theme.equals("Dark")){
tcolor = COLORS.get("Black");
setTints("#e0e0e0", 0x000000);
}else if(theme.equals("System Wallpaper")||theme.equals("Wallpaper with Header")){
setTints("#ffffff", 0xff0000);
if(this instanceof Apps||prefs.getBoolean("transonwallpaper",false)) {
tcolor = Color.TRANSPARENT;
}else{
tcolor = Color.WHITE;
}
}else{
tcolor = Integer.parseInt(theme.split(":")[1]);
if(bgColor==Card.DEFAULT_COLOR){
bgColor = Integer.parseInt(theme.split(":")[0]);
}
}
if(bgColor!=Card.DEFAULT_COLOR){
if(bgColor==Color.WHITE){
setTints("#555555",bgColor);
}else if(bgColor==Color.BLACK){
setTints("#e0e0e0",bgColor);
}else if(bgColor==Color.TRANSPARENT){
setTints("#ffffff",bgColor);
}else if(MainActivity.useBlackText(bgColor)){
setTints("#222222",bgColor);
}else{
setTints("#ffffff",bgColor);
}
}
if (rcolor == Card.DEFAULT_COLOR) rcolor = tcolor;
if (rcolor == Card.NO_CARD_COLOR) rcolor = Color.TRANSPARENT;
v.setCardBackgroundColor(rcolor);
trueColor = rcolor;
if (this instanceof Apps) {
Apps a = (Apps) this;
if (a.getNumApps() == 1) {
a.adapter.notifyDataSetChanged();
}
}
if(rcolor == Color.TRANSPARENT){
v.setCardElevation(0);
//wrapper.setShowMode(SwipeLayout.ShowMode.PullOut);
}else{
v.setCardElevation(ONE_DP * 4);
//wrapper.setShowMode(SwipeLayout.ShowMode.LayDown);
}
if(Build.VERSION.SDK_INT>=21) {
v.setClipToOutline(true);
}
}
示例13: setAppointmentTexts
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
private void setAppointmentTexts()
{
//Set the dynamic layout with appointment texts
if(fireBaseMap!=null) {
for (String s : appointmentTexts) {
//Card view of the dynamic layout
CardView cardView = new CardView(Appoinments.this);
LinearLayout.LayoutParams lp = (new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
150));
lp.setMargins(18, 20, 18, 20);
cardView.setLayoutParams(lp);
cardView.setCardBackgroundColor(0xff63D5C3);
cardView.setPadding(30, 30, 30, 30);
//Text view of the dynamic layout
TextView textView = new TextView(Appoinments.this);
LinearLayout.LayoutParams layoutParams = (new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT));
textView.setLayoutParams(layoutParams);
textView.setGravity(Gravity.CENTER);
textView.setText(s);
textView.setTextColor(0xff000000); // hex color 0xAARRGGBB
textView.setTextSize(16);
textView.setTypeface(Typeface.create("monospace", Typeface.NORMAL));
//Add the text view to card view
cardView.addView(textView);
//Add the card view to linear layout
verticalLayout.addView(cardView);
}
//Set the number of appointments to a text view
String numberOfAppointments = getString(R.string.appointment) + String.valueOf(listOfAppointments.size());
appointmentTextView.setText(numberOfAppointments);
}
}
示例14: createFabMenuItem
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
private View createFabMenuItem(MenuItem menuItem) {
ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext())
.inflate(getMenuItemLayoutId(), this, false);
FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab);
CardView cardView = (CardView) fabMenuItem.findViewById(R.id.card_view);
TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view);
fabMenuItemMap.put(miniFab, menuItem);
cardViewMenuItemMap.put(cardView, menuItem);
miniFab.setImageDrawable(menuItem.getIcon());
miniFab.setOnClickListener(this);
cardView.setOnClickListener(this);
ViewCompat.setAlpha(miniFab, 0f);
ViewCompat.setAlpha(cardView, 0f);
final CharSequence title = menuItem.getTitle();
if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) {
cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor());
titleView.setText(title);
titleView.setTypeface(null, Typeface.BOLD);
titleView.setTextColor(miniFabTitleTextColor);
if (miniFabTitleTextColorArray != null) {
titleView.setTextColor(ContextCompat.getColorStateList(getContext(),
miniFabTitleTextColorArray[menuItem.getOrder()]));
}
} else {
fabMenuItem.removeView(cardView);
}
miniFab.setBackgroundTintList(miniFabBackgroundTint);
if (miniFabBackgroundTintArray != null) {
miniFab.setBackgroundTintList(ContextCompat.getColorStateList(getContext(),
miniFabBackgroundTintArray[menuItem.getOrder()]));
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
miniFab.setImageTintList(miniFabDrawableTint);
}
return fabMenuItem;
}
示例15: onCreateView
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
int index = getArguments().getInt("INDEX");
View v = inflater.inflate(R.layout.view_matrix_frag, container, false);
CardView cardView = (CardView) v.findViewById(R.id.DynamicCardView);
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
String string = sharedPreferences.getString("ELEVATE_AMOUNT", "4");
String string2 = sharedPreferences.getString("CARD_CHANGE_KEY", "#bdbdbd");
cardView.setCardElevation(Integer.parseInt(string));
cardView.setCardBackgroundColor(Color.parseColor(string2));
CardView.LayoutParams params1 = new CardView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
GridLayout gridLayout = new GridLayout(getContext());
gridLayout.setRowCount(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow());
gridLayout.setColumnCount(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol());
for (int i = 0; i < ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow(); i++) {
for (int j = 0; j < ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol(); j++) {
TextView textView = new TextView(getContext());
textView.setGravity(Gravity.CENTER);
textView.setText(SafeSubString(GetText(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetElementof(i, j)), getLength()));
textView.setWidth(CalculatedWidth(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol()));
textView.setTextSize(SizeReturner(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow(), ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol(),
PreferenceManager.getDefaultSharedPreferences(getContext()).
getBoolean("EXTRA_SMALL_FONT", false)));
textView.setHeight(CalculatedHeight(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow()));
GridLayout.Spec Row = GridLayout.spec(i, 1);
GridLayout.Spec Col = GridLayout.spec(j, 1);
GridLayout.LayoutParams params = new GridLayout.LayoutParams(Row, Col);
gridLayout.addView(textView, params);
}
}
gridLayout.setLayoutParams(params1);
cardView.addView(gridLayout);
// Inflate the layout for this fragment
return v;
}