Fullscreen image inside a ViewFlipper
I have a ViewFlipper in my xml layout that contains an Image. I would like to display this image fullscreen. No matter which ScaleType I use for the image I can't get the image to display fullscreen.
This is my layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ViewFlipper android:layout_height="fill_parent" android:id="@+id/flipperView" android:layout_width="fill_parent">
<FrameLayout android:id="@+id/frameLayout1" android:layout_height="fill_parent" android:layout_width="fill_parent">
<ImageView android:src="@drawable/my_drawable" android:id="@+id/bcImageView" android:layout_width="fill_parent" android:layout_gravity="center" android:scaleType="fitCenter" android:layout_height="wrap_content"></ImageView>
</FrameLayout>
</ViewFlipper>
</LinearLayout>
And this is the code in my Activity:
protected void onCreate(Bundle savedInstance开发者_如何学编程State) {
super.onCreate(savedInstanceState);
// Force landscape mode
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
// Hide window title and go fullscreen
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.flippertest);
mViewFlipper = (ViewFlipper) findViewById(R.id.flipperView);
mViewFlipper.setFocusableInTouchMode(true);
mViewFlipper.requestFocus();
mViewFlipper.setOutAnimation(this, android.R.anim.slide_out_right);
mViewFlipper.setInAnimation(this, android.R.anim.slide_in_left);
I've also tried using:
mViewFlipper.setClipChildren(false);
mViewFlipper.setMinimumHeight(300);
with various values of minimum height but nothing.
Any ideas why the image is not displayed fullscreen ?
Try to set yourImageView.setScaleType(ImageView.ScaleType.FIT_XY);
This worked for me and solved my problem.
Change your ImageView's android:layout_height="wrap_content"
to android:layout_height="fill_parent"
in your layout
精彩评论