本文整理汇总了Java中android.support.v7.widget.CardView.setUseCompatPadding方法的典型用法代码示例。如果您正苦于以下问题:Java CardView.setUseCompatPadding方法的具体用法?Java CardView.setUseCompatPadding怎么用?Java CardView.setUseCompatPadding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.CardView
的用法示例。
在下文中一共展示了CardView.setUseCompatPadding方法的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: 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: onCreateViewHolder
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
public RecyclerView.ViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
if (viewType == VIEW_TYPE_TRANSACTION) {
if (useCards) {
final CardView cardView = (CardView) inflater.inflate(R.layout.transaction_row_card, parent, false);
cardView.setPreventCornerOverlap(false);
cardView.setUseCompatPadding(true);
return new TransactionViewHolder(cardView);
} else {
return new TransactionViewHolder(inflater.inflate(R.layout.transaction_row, parent, false));
}
} else if (viewType == VIEW_TYPE_WARNING) {
return new WarningViewHolder(inflater.inflate(R.layout.transaction_row_warning, parent, false));
} else {
throw new IllegalStateException("unknown type: " + viewType);
}
}
示例4: 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) {
};
}
示例5: 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);
}
}