本文整理匯總了Java中android.support.v7.widget.CardView.getChildAt方法的典型用法代碼示例。如果您正苦於以下問題:Java CardView.getChildAt方法的具體用法?Java CardView.getChildAt怎麽用?Java CardView.getChildAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.CardView
的用法示例。
在下文中一共展示了CardView.getChildAt方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onActionClick
import android.support.v7.widget.CardView; //導入方法依賴的package包/類
@Override
protected void onActionClick(View action) {
super.onActionClick(action);
CardView cardView = (CardView) action;
RelativeLayout relativeLayout = (RelativeLayout) cardView.getChildAt(0);
ImageView imageView = (ImageView) relativeLayout.getChildAt(0);
switch ((int) imageView.getTag()) {
case R.drawable.ic_call:
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" +
event.getContact1().split(":")[1]));
startActivity(intent);
break;
case R.drawable.ic_map:
startActivity(new Intent(EventDetailActivity.this, MapsActivity.class)
.putExtra("location", event.getLocation()));
break;
}
}
示例2: onUpdateViewAlpha
import android.support.v7.widget.CardView; //導入方法依賴的package包/類
@Override
protected void onUpdateViewAlpha(@NonNull View view, float alpha) {
final CardView card = ((CardView)view);
final View alphaView = card.getChildAt(1);
final View imageView = card.getChildAt(0);
final boolean isLeftCard = alpha < 1;
if (isLeftCard) {
ViewCompat.setAlpha(alphaView, 0.9f - alpha);
ViewCompat.setAlpha(imageView, 0.3f + alpha);
} else {
if (ViewCompat.getAlpha(alphaView) != 0) {
ViewCompat.setAlpha(alphaView, 0f);
}
if (ViewCompat.getAlpha(imageView) != 1) {
ViewCompat.setAlpha(imageView, 1f);
}
}
}
示例3: onClick
import android.support.v7.widget.CardView; //導入方法依賴的package包/類
@Override
public void onClick(View view) {
final CardSliderLayoutManager lm = (CardSliderLayoutManager) recyclerView.getLayoutManager();
if (lm.isSmoothScrolling()) {
return;
}
final int activeCardPosition = lm.getActiveCardPosition();
if (activeCardPosition == RecyclerView.NO_POSITION) {
return;
}
final int clickedPosition = recyclerView.getChildAdapterPosition(view);
if (clickedPosition == activeCardPosition) {
final Intent intent = new Intent(MainActivity.this, DetailsActivity.class);
intent.putExtra(DetailsActivity.BUNDLE_IMAGE_ID, pics[activeCardPosition % pics.length]);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
startActivity(intent);
} else {
final CardView cardView = (CardView) view;
final View sharedView = cardView.getChildAt(cardView.getChildCount() - 1);
final ActivityOptions options = ActivityOptions
.makeSceneTransitionAnimation(MainActivity.this, sharedView, "shared");
startActivity(intent, options.toBundle());
}
} else if (clickedPosition > activeCardPosition) {
recyclerView.smoothScrollToPosition(clickedPosition);
onActiveCardChange(clickedPosition);
}
}
示例4: 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));
}
}
示例5: getView
import android.support.v7.widget.CardView; //導入方法依賴的package包/類
@NonNull
public View getView() {
Snackbar.SnackbarLayout snackBarLayout = (Snackbar.SnackbarLayout) mSnackBar.getView();
boolean tabletMode = mBuilder.mContext.getResources().getBoolean(R.bool.cafebar_tablet_mode);
if (tabletMode || mBuilder.mFloating) {
CardView cardView = (CardView) snackBarLayout.getChildAt(0);
return cardView.getChildAt(0);
}
LinearLayout linearLayout = (LinearLayout) snackBarLayout.getChildAt(0);
if (mBuilder.mShowShadow) return linearLayout.getChildAt(1);
return linearLayout.getChildAt(0);
}
示例6: onBindViewHolder
import android.support.v7.widget.CardView; //導入方法依賴的package包/類
@Override
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, final int position) {
Model model = items.get(position);
if (model == null) {
return;
}
RecyclerView.LayoutParams lp = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
RecyclerView.LayoutParams lp2 = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
switch (model.getType()) {
case Model.TEXT_TYPE:
case Model.COMMENT_TYPE:
TextView textView = (TextView) model.getTheContent();
((ViewHolderText) holder).text.setText(textView.getText());
((ViewHolderText) holder).text.setPadding(textView.getPaddingLeft(), textView.getPaddingTop(), textView.getPaddingRight(), textView.getPaddingBottom());
((ViewHolderText) holder).text.setTypeface(textView.getTypeface());
((ViewHolderText) holder).text.setTextColor(textView.getCurrentTextColor());
if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
((ViewHolderText) holder).text.setBackground(textView.getBackground());
}
if (textView.getBackground() != null) {
((ViewHolderText) holder).text.setAllCaps(true);
}
// Tag doesn't expand horizontally to the max
if (textView.getLayoutParams() != null) {
((ViewHolderText) holder).text.setLayoutParams(textView.getLayoutParams());
} else {
((ViewHolderText) holder).text.setLayoutParams(lp);
}
((ViewHolderText) holder).text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textView.getTextSize());
break;
case Model.IMAGE_TYPE:
String imageURI = (String) model.getTheContent();
((ViewHolderImage) holder).image.setLayoutParams(lp);
Picasso.with(((ViewHolderImage) holder).image.getContext()).load(imageURI).into(((ViewHolderImage) holder).image);
break;
case Model.TWEET_TYPE:
CardView cardView = (CardView) model.getTheContent();
TextView tweet = (TextView) cardView.getChildAt(0);
Button link = (Button) cardView.getChildAt(1);
((ViewHolderTweet) holder).getTweet().setText(tweet.getText());
((ViewHolderTweet) holder).getLink().setContentDescription(link.getContentDescription());
break;
case Model.GRAPH_TYPE_BARS:
Chart chart1 = (Chart) model.getTheContent();
((ViewHolderChart) holder).chart.setData(chart1.getData());
((ViewHolderChart) holder).chart.setLayoutParams(lp2);
break;
case Model.GRAPH_TYPE_COLUMNS:
Chart chart2 = (Chart) model.getTheContent();
((ViewHolderChart) holder).chart.setData(chart2.getData());
((ViewHolderChart) holder).chart.setLayoutParams(lp2);
break;
}
}