本文整理汇总了Java中android.support.v7.widget.CardView.setCardElevation方法的典型用法代码示例。如果您正苦于以下问题:Java CardView.setCardElevation方法的具体用法?Java CardView.setCardElevation怎么用?Java CardView.setCardElevation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.CardView
的用法示例。
在下文中一共展示了CardView.setCardElevation方法的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: init
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
private void init() {
LinearLayout frame = new LinearLayout(context);
CardView card = new CardView(context);
card.setUseCompatPadding(true);
card.setContentPadding(MainActivity.dp(8), MainActivity.dp(8), MainActivity.dp(8), MainActivity.dp(8));
card.setCardElevation(12.f);
card.addView(layout);
frame.addView(card);
this.setContentView(frame);
this.setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
this.setFocusable(true);
this.setBackgroundDrawable(new BitmapDrawable());
this.setOutsideTouchable(true);
}
示例3: onLongClick
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
void onLongClick() {
Task currentTask = taskList.get(position);
CardView cardView = (CardView)itemView;
float initialElevation = cardView.getCardElevation();
cardView.setCardElevation(cardView.getCardElevation() * 15);
PopupMenu menu = new PopupMenu(context, itemView);
menu.inflate(R.menu.pop_up_menu);
menu.setOnMenuItemClickListener(item -> {
switch (item.getItemId()){
case R.id.edit_task:
actions.editTask(currentTask, position);
return true;
case R.id.delete_task:
actions.deleteTask(currentTask, position);
}
return false;
});
menu.setOnDismissListener(popupMenu ->
cardView.setCardElevation(initialElevation));
menu.show();
}
示例4: ContributorsViewHolder
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
ContributorsViewHolder(View itemView) {
super(itemView);
TextView title = itemView.findViewById(R.id.title);
CardView card = itemView.findViewById(R.id.card);
if (!Preferences.get(mContext).isShadowEnabled() && card != null) {
card.setCardElevation(0);
}
int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
mContext, R.drawable.ic_toolbar_people, color), null, null, null);
title.setText(mContext.getResources().getString(R.string.about_contributors_title));
title.setOnClickListener(this);
}
示例5: FooterViewHolder
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
FooterViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
CardView card = itemView.findViewById(R.id.card);
if (!Preferences.get(mContext).isShadowEnabled() && card != null) {
card.setCardElevation(0);
}
int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
TextView title = itemView.findViewById(R.id.about_dashboard_title);
title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
mContext, R.drawable.ic_toolbar_dashboard, color), null, null, null);
instagram.setImageDrawable(DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_toolbar_instagram, color));
googlePlus.setImageDrawable(DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_toolbar_google_plus, color));
github.setImageDrawable(DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_toolbar_github, color));
instagram.setOnClickListener(this);
googlePlus.setOnClickListener(this);
github.setOnClickListener(this);
licenses.setOnClickListener(this);
contributors.setOnClickListener(this);
translator.setOnClickListener(this);
}
示例6: updateView
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
public void updateView(@NonNull View view, float position) {
super.updateView(view, position);
final CardView card = ((CardView)view);
final View alphaView = card.getChildAt(1);
final View imageView = card.getChildAt(0);
if (position < 0) {
final float alpha = ViewCompat.getAlpha(view);
ViewCompat.setAlpha(view, 1f);
ViewCompat.setAlpha(alphaView, 0.9f - alpha);
ViewCompat.setAlpha(imageView, 0.3f + alpha);
} else {
ViewCompat.setAlpha(alphaView, 0f);
ViewCompat.setAlpha(imageView, 1f);
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
final CardSliderLayoutManager lm = getLayoutManager();
final float ratio = (float) lm.getDecoratedLeft(view) / lm.getActiveCardLeft();
final float z;
if (position < 0) {
z = Z_CENTER_1 * ratio;
} else if (position < 0.5f) {
z = Z_CENTER_1;
} else if (position < 1f) {
z = Z_CENTER_2;
} else {
z = Z_RIGHT;
}
card.setCardElevation(Math.max(0, z));
}
}
示例7: onCreateViewHolder
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int position) {
View view;
if (mItems.get(position).cacheable()) {
if (mViews.containsKey(mItems.get(position))) {
view = mViews.get(mItems.get(position));
} else {
mViews.put(mItems.get(position), view = LayoutInflater.from(parent.getContext())
.inflate(mItems.get(position).getLayoutRes(), parent, false));
}
} else {
view = LayoutInflater.from(parent.getContext())
.inflate(mItems.get(position).getLayoutRes(), parent, false);
}
ViewGroup viewGroup = (ViewGroup) view.getParent();
if (viewGroup != null) {
viewGroup.removeView(view);
}
if (mItems.get(position).cardCompatible()
&& Prefs.getBoolean("forcecards", false, view.getContext())) {
CardView cardView = new CardView(view.getContext());
cardView.setRadius(view.getResources().getDimension(R.dimen.cardview_radius));
cardView.setCardElevation(view.getResources().getDimension(R.dimen.cardview_elevation));
cardView.setUseCompatPadding(true);
cardView.setFocusable(false);
cardView.addView(view);
view = cardView;
}
if (position == 0) {
mFirstItem = view;
}
mItems.get(position).setOnViewChangeListener(mOnViewChangedListener);
mItems.get(position).onCreateHolder(parent, view);
return new RecyclerView.ViewHolder(view) {
};
}
示例8: addView
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
public void addView(View child) {
if (child instanceof NavigationView) {
super.addView(child);
} else {
CardView cardView = new CardView(getContext());
cardView.setRadius(0);
cardView.addView(child);
cardView.setCardElevation(0);
frameLayout.addView(cardView);
}
}
示例9: onChildDraw
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
if (mBeingDrawn) {
mBeingDrawn = false;
} else {
CardView cardView = (CardView) viewHolder.itemView.findViewById(R.id.background);
cardView.setCardElevation(16);
cardView.setBackgroundColor(ContextCompat.getColor(viewHolder.itemView.getContext(), R.color.white));
}
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
}
示例10: onPageScrolled
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
int realCurrentPosition;
int nextPosition;
float baseElevation = mAdapter.getBaseElevation();
float realOffset;
boolean goingLeft = mLastOffset > positionOffset;
// If we're going backwards, onPageScrolled receives the last position
// instead of the current one
if (goingLeft) {
realCurrentPosition = position + 1;
nextPosition = position;
realOffset = 1 - positionOffset;
} else {
nextPosition = position + 1;
realCurrentPosition = position;
realOffset = positionOffset;
}
// Avoid crash on overscroll
if (nextPosition > mAdapter.getCount() - 1
|| realCurrentPosition > mAdapter.getCount() - 1) {
return;
}
CardView currentCard = mAdapter.getCardViewAt(realCurrentPosition);
// This might be null if a fragment is being used
// and the views weren't created yet
if (currentCard != null) {
if (mScalingEnabled) {
currentCard.setScaleX((float) (1 + 0.1 * (1 - realOffset)));
currentCard.setScaleY((float) (1 + 0.1 * (1 - realOffset)));
}
currentCard.setCardElevation((baseElevation + baseElevation
* (CardAdapter.MAX_ELEVATION_FACTOR - 1) * (1 - realOffset)));
}
CardView nextCard = mAdapter.getCardViewAt(nextPosition);
// We might be scrolling fast enough so that the next (or previous) card
// was already destroyed or a fragment might not have been created yet
if (nextCard != null) {
if (mScalingEnabled) {
nextCard.setScaleX((float) (1 + 0.1 * (realOffset)));
nextCard.setScaleY((float) (1 + 0.1 * (realOffset)));
}
nextCard.setCardElevation((baseElevation + baseElevation
* (CardAdapter.MAX_ELEVATION_FACTOR - 1) * (realOffset)));
}
mLastOffset = positionOffset;
}
示例11: HeaderViewHolder
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
HeaderViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
RecyclerView recyclerView = itemView.findViewById(R.id.recyclerview);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, true));
recyclerView.setHasFixedSize(true);
String[] urls = mContext.getResources().getStringArray(R.array.about_social_links);
if (urls.length == 0) {
recyclerView.setVisibility(View.GONE);
subtitle.setPadding(
subtitle.getPaddingLeft(),
subtitle.getPaddingTop(),
subtitle.getPaddingRight(),
subtitle.getPaddingBottom() + mContext.getResources().getDimensionPixelSize(R.dimen.content_margin));
} else {
if (recyclerView.getLayoutParams() instanceof LinearLayout.LayoutParams) {
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) recyclerView.getLayoutParams();
if (urls.length < 7) {
params.width = LinearLayout.LayoutParams.WRAP_CONTENT;
params.gravity = Gravity.CENTER_HORIZONTAL;
recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
}
}
recyclerView.setAdapter(new AboutSocialAdapter(mContext, urls));
}
subtitle.setHtml(mContext.getResources().getString(R.string.about_desc));
CardView card = itemView.findViewById(R.id.card);
if (!Preferences.get(mContext).isShadowEnabled()) {
if (card != null) card.setCardElevation(0);
profile.setShadowRadius(0f);
profile.setShadowColor(Color.TRANSPARENT);
}
}
示例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: onPageScrolled
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
int realCurrentPosition;
int nextPosition;
float baseElevation = mAdapter.getBaseElevation();
float realOffset;
boolean goingLeft = mLastOffset > positionOffset;
// If we're going backwards, onPageScrolled receives the last position
// instead of the current one
if (goingLeft) {
realCurrentPosition = position + 1;
nextPosition = position;
realOffset = 1 - positionOffset;
} else {
nextPosition = position + 1;
realCurrentPosition = position;
realOffset = positionOffset;
}
// Avoid crash on overscroll
if (nextPosition > mAdapter.getCount() - 1
|| realCurrentPosition > mAdapter.getCount() - 1) {
return;
}
CardView currentCard = mAdapter.getCardViewAt(realCurrentPosition);
// This might be null if a fragment is being used
// and the views weren't created yet
if (currentCard != null) {
if (mScalingEnabled) {
currentCard.setScaleX((float) (1 + 0.1 * (1 - realOffset)));
currentCard.setScaleY((float) (1 + 0.1 * (1 - realOffset)));
}
currentCard.setCardElevation((baseElevation + baseElevation
* (TeamInterface.MAX_ELEVATION_FACTOR - 1) * (1 - realOffset)));
}
CardView nextCard = mAdapter.getCardViewAt(nextPosition);
// We might be scrolling fast enough so that the next (or previous) card
// was already destroyed or a fragment might not have been created yet
if (nextCard != null) {
if (mScalingEnabled) {
nextCard.setScaleX((float) (1 + 0.1 * (realOffset)));
nextCard.setScaleY((float) (1 + 0.1 * (realOffset)));
}
nextCard.setCardElevation((baseElevation + baseElevation
* (TeamInterface.MAX_ELEVATION_FACTOR - 1) * (realOffset)));
}
mLastOffset = positionOffset;
}
示例14: 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;
}
示例15: onCreateView
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View V = inflater.inflate(R.layout.fragment_edit, container, false);
CardView cardView = (CardView) V.findViewById(R.id.EditMatrixCard);
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);
int index = getArguments().getInt("INDEX");
Matrix m = ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index);
GridLayout gridLayout = new GridLayout(getContext());
gridLayout.setRowCount(m.GetRow());
gridLayout.setColumnCount(m.GetCol());
for (int i = 0; i < m.GetRow(); i++) {
for (int j = 0; j < m.GetCol(); j++) {
EditText editText = new EditText(getContext());
editText.setId(i * 10 + j);
editText.setGravity(Gravity.CENTER);
if (!PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("DECIMAL_USE", true)) {
editText.setInputType(InputType.TYPE_CLASS_NUMBER
| InputType.TYPE_NUMBER_FLAG_SIGNED);
} else {
editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL
| InputType.TYPE_NUMBER_FLAG_SIGNED);
}
editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(getLength())});
if (!PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("SMART_FIT_KEY", false)) {
editText.setWidth(ConvertTopx(62));
editText.setTextSize(SizeReturner(3, 3, PreferenceManager.getDefaultSharedPreferences(getContext()).
getBoolean("EXTRA_SMALL_FONT", false)));
} else {
editText.setWidth(ConvertTopx(CalculatedWidth(m.GetCol())));
editText.setTextSize(SizeReturner(m.GetRow(), m.GetCol(),
PreferenceManager.getDefaultSharedPreferences(getContext()).
getBoolean("EXTRA_SMALL_FONT", false)));
}
editText.setText(SafeSubString(GetText(m.GetElementof(i, j)), getLength()));
editText.setSingleLine();
GridLayout.Spec Row = GridLayout.spec(i, 1);
GridLayout.Spec Col = GridLayout.spec(j, 1);
GridLayout.LayoutParams params = new GridLayout.LayoutParams(Row, Col);
gridLayout.addView(editText, params);
}
}
gridLayout.setLayoutParams(params1);
cardView.addView(gridLayout);
RootView = V;
return V;
}