android - 使用 "match_parent"将图像对齐到顶部

标签 android android-layout android-imageview

我的申请有问题。我有一张横跨整个屏幕 (ImageView) 的图像,其中包含以下 xml 代码:

    <ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentRight="true"
    android:src="@drawable/achtergrond"
    android:scaleType="fitCenter" />

我的问题是图像位于 imageview 本身的中心。它需要居中,如下图所示:

enter image description here 左边的图片是我的,中间是图片。右边是我想要的,图像应该在整个布局中,我需要将我的图像设置为 match_parent 以将其填充为背景(我没有将其设置为背景,因为它会被拉伸(stretch))。

我希望我遗漏了一些明显的东西!感谢您提前帮助我!

最佳答案

<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/achtergrond"
    android:scaleType="fitStart" />

关于android - 使用 "match_parent"将图像对齐到顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16741074/

相关文章:

java - 如何在 Android 中处理多个 ImageView 而不会出现内存问题?

Android WebView 的 window.innerWidth 来了 313

Android - 获取隐藏图像和文件夹的快速方法

android - 如何检查已解析的 XML 标记值是否为空

Android:如何对齐底部的复选框文本?

java - 如何获取 TranslateAnimation 中的位置?

android - 如何检查文件是否存在于Android设备的特定文件夹中

java - Android Java : R. id.variable1..variable2..variable3..etc

android - ImageView 内存不足异常

Android:发送带有来自 ImageView 的图像的电子邮件