am 1eaf20c6: am d18c4a82: Merge "SupportLeanbackDemo: show case of different image scale type" into lmp-mr1-dev
* commit '1eaf20c653e3223be91774687f5249229693bffd': SupportLeanbackDemo: show case of different image scale type
This commit is contained in:
@@ -23,11 +23,14 @@ import android.view.View.MeasureSpec;
|
|||||||
import android.view.ViewGroup.LayoutParams;
|
import android.view.ViewGroup.LayoutParams;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class CardPresenter extends Presenter {
|
public class CardPresenter extends Presenter {
|
||||||
private static final String TAG = "CardPresenter";
|
private static final String TAG = "CardPresenter";
|
||||||
|
|
||||||
private static final int IMAGE_HEIGHT_DP = 120;
|
private static final int IMAGE_HEIGHT_DP = 120;
|
||||||
|
|
||||||
|
private static Random sRand = new Random();
|
||||||
private static int sRowHeight = 0;
|
private static int sRowHeight = 0;
|
||||||
private static int sExpandedRowHeight = 0;
|
private static int sExpandedRowHeight = 0;
|
||||||
|
|
||||||
@@ -62,8 +65,17 @@ public class CardPresenter extends Presenter {
|
|||||||
ImageCardView v = new ImageCardView(parent.getContext());
|
ImageCardView v = new ImageCardView(parent.getContext());
|
||||||
v.setFocusable(true);
|
v.setFocusable(true);
|
||||||
v.setFocusableInTouchMode(true);
|
v.setFocusableInTouchMode(true);
|
||||||
|
// Randomly makes image view crop as a square or just stretch to original
|
||||||
|
// aspect ratio.
|
||||||
|
if (sRand.nextBoolean()) {
|
||||||
|
v.setMainImageAdjustViewBounds(false);
|
||||||
|
v.setMainImageDimensions(getRowHeight(parent.getContext()),
|
||||||
|
getRowHeight(parent.getContext()));
|
||||||
|
} else {
|
||||||
v.setMainImageAdjustViewBounds(true);
|
v.setMainImageAdjustViewBounds(true);
|
||||||
v.setMainImageDimensions(LayoutParams.WRAP_CONTENT, getRowHeight(parent.getContext()));
|
v.setMainImageDimensions(LayoutParams.WRAP_CONTENT,
|
||||||
|
getRowHeight(parent.getContext()));
|
||||||
|
}
|
||||||
return new ViewHolder(v);
|
return new ViewHolder(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user