ViewFlipper不能正确缠绕图像 [英] ViewFlipper not wrapping around images correctly

查看:117
本文介绍了ViewFlipper不能正确缠绕图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ViewFlipper里面的一些ImageViews。我想的尊重宽高比图像,所以布局将不能使用所有画面。我已经建立了一个简单的滑动的动画,但ViewFlipper永远比里面的图片大一点。这使得一个不需要的黑色空间两个滑动图像之间出现。我不能让ViewFlipper环绕ImageViews正确。

I have some ImageViews inside a ViewFlipper. I want to respect the aspect ratio of the images, so the layout won't use all the screen. I have set up a simple "slide" animation, but the ViewFlipper will always be a bit bigger than the images inside. This makes an undesired black space appear between two sliding images. I can't make the ViewFlipper wrap around the ImageViews correctly.

一切都是里面的FrameLayout,所以我可以有一个浮动按钮有太多。这是主要的布局XML:

Everything is inside a FrameLayout, so there I can have a floating button there too. This is the main layout XML:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainLayout"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:scaleType="centerInside"
    > 
 <ViewFlipper
     android:id="@+id/flipper"
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"
     android:layout_gravity="center"   
     android:scaleType="centerInside"
     >
  <ImageView 
      android:id="@+id/page1"   
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"
      android:scaleType="centerInside"
      android:src="@drawable/bg0"
      />
  <ImageView 
      android:id="@+id/page2"   
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"
      android:scaleType="centerInside"
      android:src="@drawable/bg1"
      />   
 </ViewFlipper>
 <ImageButton
  android:id="@+id/menuButton"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="bottom"
  android:src="@drawable/btn_menu"
  android:background="@null"
  />    
</FrameLayout>

如果我设置了ImageViews为fitXY黑缘消失的scaleType,但图像的比例不尊重。我已经尝试fitCenter,fillParent的ImageViews和0像素的填充。

If I set the scaleType of the ImageViews to "fitXY" the black margin disappears, but the ratio of the images is not respected. I have already tried "fitCenter", "fillParent" in the ImageViews, and a padding of 0px.

任何帮助是pciated因为我一直在这个挣扎了几个小时非常AP $ P $。

Any help is very much appreciated as I have been struggling with this for hours.

推荐答案

添加此到ImageView的做到了:

Adding this to the ImageView did it:

android:adjustViewBounds="true"

这篇关于ViewFlipper不能正确缠绕图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆