ViewFlipper 内的全屏图像
我的 xml 布局中有一个包含图像的 ViewFlipper。我想全屏显示该图像。无论我对图像使用哪种 ScaleType,我都无法让图像全屏显示。
这是我的布局:
<?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>
这是我的活动中的代码:
protected void onCreate(Bundle savedInstanceState) {
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);
我还尝试使用:
mViewFlipper.setClipChildren(false);
mViewFlipper.setMinimumHeight(300);
具有各种最小高度值,但什么也没有。
任何想法为什么图像不全屏显示?
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 savedInstanceState) {
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试设置
yourImageView.setScaleType(ImageView.ScaleType.FIT_XY);
这对我有用并解决了我的问题。Try to set
yourImageView.setScaleType(ImageView.ScaleType.FIT_XY);
This worked for me and solved my problem.将布局中的 ImageView 的
android:layout_height="wrap_content"
更改为android:layout_height="fill_parent"
Change your ImageView's
android:layout_height="wrap_content"
toandroid:layout_height="fill_parent"
in your layout