diff --git a/samples/Support7Demos/res/layout/activity_card_view.xml b/samples/Support7Demos/res/layout/activity_card_view.xml index cfd307142..9b985f70e 100644 --- a/samples/Support7Demos/res/layout/activity_card_view.xml +++ b/samples/Support7Demos/res/layout/activity_card_view.xml @@ -123,13 +123,61 @@ android:layout_height="wrap_content" android:layout_toRightOf="@id/alpha_label" android:layout_alignTop="@id/alpha_label"/> - + + + + + + + + + + android:layout_below="@id/color_label"> - @@ -155,9 +202,10 @@ card_view:cardElevation="10dp"> + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> #770000ff + #FCF0AD + #FCF0AD + #BAB7A9 + #F9D6AC + #56C4E8 diff --git a/samples/Support7Demos/res/values/strings.xml b/samples/Support7Demos/res/values/strings.xml index 03282affd..789e19ef8 100644 --- a/samples/Support7Demos/res/values/strings.xml +++ b/samples/Support7Demos/res/values/strings.xml @@ -150,6 +150,7 @@ Radius Width Height + Background Elevation Max Elevation Alpha diff --git a/samples/Support7Demos/src/com/example/android/supportv7/view/CardViewActivity.java b/samples/Support7Demos/src/com/example/android/supportv7/view/CardViewActivity.java index ba4f0cb1d..ca0c08aac 100644 --- a/samples/Support7Demos/src/com/example/android/supportv7/view/CardViewActivity.java +++ b/samples/Support7Demos/src/com/example/android/supportv7/view/CardViewActivity.java @@ -16,6 +16,8 @@ package com.example.android.supportv7.view; import android.app.Activity; +import android.graphics.drawable.ColorDrawable; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.support.v4.view.ViewCompat; @@ -25,8 +27,11 @@ import android.view.ViewGroup; import android.widget.RadioGroup; import android.widget.SeekBar; import android.widget.TextView; + import com.example.android.supportv7.R; +import java.lang.reflect.Field; + public class CardViewActivity extends Activity { CardView mCardView; @@ -84,7 +89,7 @@ public class CardViewActivity extends Activity { lp = setViewBounds(mInfoText); } mInfoText.setText("radius: " + mCornerRadiusSeekBar.getProgress() - +", alpha: " + mAlphaSeekBar.getProgress() + + ", alpha: " + mAlphaSeekBar.getProgress() + "\n w: " + lp.width + "\nh: " + lp.height + "\nelevation: " + mCardView.getCardElevation() + " of " + mCardView.getMaxCardElevation()); @@ -143,15 +148,42 @@ public class CardViewActivity extends Activity { } }); - update(); new Handler().postDelayed(new Runnable() { @Override public void run() { View content = findViewById(android.R.id.content); + mWidthSeekBar.setProgress(mCardView.getWidth()); + mHeightSeekBar.setProgress(mCardView.getHeight()); mWidthSeekBar.setMax(content.getWidth()); mHeightSeekBar.setMax(content.getHeight()); + update(); } }, 100); + + ((RadioGroup) findViewById(R.id.select_bg_color_radio)) + .setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(RadioGroup group, int checkedId) { + mCardView.setCardBackgroundColor( + getResources().getColor(getColorId(checkedId))); + } + }); } + private int getColorId(int id) { + switch (id) { + case R.id.yellow: + return R.color.card_yellow; + case R.id.aquatic: + return R.color.card_aquatic; + case R.id.classic: + return R.color.card_classic; + case R.id.sunbrite: + return R.color.card_sunbrite; + case R.id.tropical: + return R.color.card_tropical; + default: + return R.color.cardview_light_background; + } + } } diff --git a/samples/Support7Demos/src/com/example/android/supportv7/widget/AnimatedRecyclerView.java b/samples/Support7Demos/src/com/example/android/supportv7/widget/AnimatedRecyclerView.java index 50fe1e1a8..b503bcf0e 100644 --- a/samples/Support7Demos/src/com/example/android/supportv7/widget/AnimatedRecyclerView.java +++ b/samples/Support7Demos/src/com/example/android/supportv7/widget/AnimatedRecyclerView.java @@ -480,7 +480,7 @@ public class AnimatedRecyclerView extends Activity { } public void selectItem(MyViewHolder holder, boolean selected) { - mSelected.put((String) holder.textView.getText(), selected); + mSelected.put((String) holder.textView.getText().toString(), selected); } public void toggleExpanded(MyViewHolder holder) {