【问题标题】:Fullscreen image inside a ViewFlipperViewFlipper 中的全屏图像
【发布时间】:2011-09-03 23:49:55
【问题描述】:

我的 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>

这是我 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);

我也尝试过使用:

    mViewFlipper.setClipChildren(false);
    mViewFlipper.setMinimumHeight(300);

具有各种最小高度值,但什么都没有。

任何想法为什么图像没有全屏显示?

【问题讨论】:

  • 你有没有让这个工作?有类似的问题
  • 不,我完全重新设计了 UI。
  • 正在考虑同样的事情!

标签: android image fullscreen viewflipper


【解决方案1】:

尝试设置yourImageView.setScaleType(ImageView.ScaleType.FIT_XY); 这对我有用并解决了我的问题。

【讨论】:

    【解决方案2】:

    在布局中将 ImageView 的 android:layout_height="wrap_content" 更改为 android:layout_height="fill_parent"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-18
      • 2019-10-20
      • 2011-07-31
      • 2012-05-14
      • 1970-01-01
      • 2021-12-15
      相关资源
      最近更新 更多