1

我将 ImageView 的 layout_gravity 设置为“右”并尝试将 0px 填充静态分配给所有四个边缘,但我仍然在屏幕右侧得到奇怪的大约 10px“填充”。此问题仅发生在横向。在垂直方向上,图像正确缩放并且没有发生填充。

XML 文件如下所示:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:padding="0px"
  android:layout_width="match_parent"
  android:layout_height="match_parent" >

<SurfaceView
  android:id="@+id/surfaceview"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:layout_gravity="center"
/>

<ImageView 
  android:id="@+id/img1"
  android:src="@drawable/testimage"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="right"
/>    
</FrameLayout>

图像尺寸为 720x405,我的设备屏幕为 800x480。

4

0 回答 0