本文整理汇总了Java中android.support.v7.widget.CardView.setLayoutParams方法的典型用法代码示例。如果您正苦于以下问题:Java CardView.setLayoutParams方法的具体用法?Java CardView.setLayoutParams怎么用?Java CardView.setLayoutParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.CardView
的用法示例。
在下文中一共展示了CardView.setLayoutParams方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: ViewHolder
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
public ViewHolder(View itemView) {
super(itemView);
cardView = (CardView) itemView;
cover = (FrameLayout) itemView.findViewById(R.id.cover_layout);
imageButton = (ImageButton) itemView.findViewById(R.id.rank_image);
categoryName = (TextView) itemView.findViewById(R.id.category_name);
if (mActivity instanceof RecyclerViewActivity) {
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
TranslateDptoPiexel.translate(210, mActivity));
cardView.setLayoutParams(params);
}
}
示例3: initZoomRegionView
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
/**
* Init the ZoomRegionView for navigate into image when user zoom in
*/
private void initZoomRegionView() {
if (mZoomRegionView == null) {
Bitmap init = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
mContentBitmap = init.copy(Bitmap.Config.ARGB_8888, true);
init.recycle();
mContentCanvas = new Canvas(mContentBitmap);
FrameLayout.LayoutParams layoutParams = new LayoutParams(getWidth() / 4, getHeight() / 4,
Gravity.TOP | Gravity.END);
layoutParams.setMargins(12, 12, 12, 12);
mZoomRegionCardView = new CardView(getContext());
mZoomRegionCardView.setLayoutParams(layoutParams);
mZoomRegionCardView.setPreventCornerOverlap(true);
mZoomRegionCardView.setRadius(0f);
mZoomRegionCardView.setUseCompatPadding(true);
mZoomRegionCardView.setVisibility(View.INVISIBLE);
CardView.LayoutParams childLayoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
mZoomRegionView = new ZoomRegionView(getContext());
mZoomRegionView.setLayoutParams(childLayoutParams);
mZoomRegionView.setScaleType(ImageView.ScaleType.CENTER_CROP);
mZoomRegionView.setOnZoomRegionListener(new ZoomRegionView.OnZoomRegionListener() {
@Override
public void onZoomRegionMoved(Rect newRect) {
mFromZoomRegion = true;
mZoomCenterX = newRect.centerX() * 4;
mZoomCenterY = newRect.centerY() * 4;
invalidate();
}
});
mZoomRegionCardView.addView(mZoomRegionView);
addView(mZoomRegionCardView);
}
}
示例4: updateSlideOffset
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
private void updateSlideOffset(View drawerView, float slideOffset) {
final int absHorizGravity = getDrawerViewAbsoluteGravity(Gravity.START);
final int childAbsGravity = getDrawerViewAbsoluteGravity(drawerView);
for (int i = 0; i < frameLayout.getChildCount(); i++) {
CardView child = (CardView) frameLayout.getChildAt(i);
Setting setting = settings.get(childAbsGravity);
float adjust = 0;
if (setting != null) {
child.setRadius((int) (setting.radius * slideOffset));
super.setScrimColor(setting.scrimColor);
super.setDrawerElevation(setting.drawerElevation);
float percentage = 1f - setting.percentage;
float reduceHeight = getHeight() * percentage * slideOffset;
FrameLayout.LayoutParams params
= (FrameLayout.LayoutParams) child.getLayoutParams();
params.topMargin = (int) (reduceHeight / 2);
params.bottomMargin = (int) (reduceHeight / 2);
child.setLayoutParams(params);
child.setCardElevation(setting.elevation * slideOffset);
adjust = setting.elevation;
float width = childAbsGravity == absHorizGravity ?
drawerView.getWidth() + adjust : -drawerView.getWidth() - adjust;
ViewCompat.setX(child, width * slideOffset);
} else {
super.setScrimColor(defaultScrimColor);
super.setDrawerElevation(defaultDrawerElevation);
}
}
}
示例5: 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);
}
}