【发布时间】:2018-08-09 12:18:22
【问题描述】:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="galleryimages.galleryimages.Main2Activity"
android:background="#000000"
android:id="@+id/linear1">
<ImageView
android:id="@+id/iv_image2"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_above="@+id/button1"
android:layout_weight="0"
android:layout_gravity="center"
tools:ignore="InvalidId" />
<ImageButton
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:adjustViewBounds="false"
android:background="#ffffff"
android:gravity="bottom"
android:src="@drawable/ic_delete_black_24dp" />
</RelativeLayout>
我希望图像填满整个屏幕。我应该为 18:9 比例的手机编写单独的代码吗?另外,如果我删除一张图片,它不会与谷歌照片同步。
【问题讨论】:
-
鉴于您不想拥有黑色,我建议添加
android:scaleType="centerCrop"。这将适合图像,因此它会填满屏幕。使用反映手机纵横比的图像将减少裁剪。使用 fitXY 会导致图像从其原始纵横比变形。
标签: android android-layout android-studio