【问题标题】:ImageView in splashScreen is showed blurredsplashScreen 中的 ImageView 显示模糊
【发布时间】:2019-04-04 16:10:14
【问题描述】:

我正在为我的应用程序实现一个启动画面,当它运行时,启动画面包含一个模糊的图像,而不是应该的样子。

<ImageView
    android:id="@+id/imageView"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:scaleType="centerCrop"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.0"
    tools:srcCompat="@mipmap/ic_launcher_foreground" />

我必须选择哪一个?或者我该如何添加图像?因为图片是2700x2700px... 我将 imageView 作为 centerCrop。

【问题讨论】:

标签: android uiimageview android-xml splash-screen


【解决方案1】:

将图像尺寸减小 75% - (675 x 675)。对于手机布局来说,绰绰有余。您可以使用此在线工具在不更改纵横比的情况下更改图像的尺寸:

https://www.iloveimg.com/resize-image/resize-png

【讨论】:

    【解决方案2】:

    如果您使用裸 React-Native 进行开发,请在您的:android -> app -> src -> main -> res 文件夹中,创建文件夹 drawable-v21、drawable-v22 和 drawable-v24。 就像发生在我身上一样,这样做的原因是;闪屏肯定会在其他设备上出现失真。但是通过这些文件夹结构,这些设备肯定会按照 SDK 的指示使用这些文件夹中分配的资源。因此,在这些文件夹中,创建一个文件:background_splash.xml,其内容如下:

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item
            android:drawable="@color/splashscreen_bg"
        />
        <item
            android:bottom="280dp"
            android:left="70dp"
            android:right="70dp"
            android:top="280dp"
        >
            <bitmap
                android:gravity="fill"
                android:src="@drawable/turbo_logo" />  <!-- this should contain the location of your splashscreen image -->
        </item>
    </layer-list>
    

    您需要将底部和顶部、左侧和右侧的值迭代为优化值。但是,顶部和底部必须相同;另外,left 和 right 必须相同。

    【讨论】:

      猜你喜欢
      • 2020-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-07
      • 2014-03-18
      • 2016-02-24
      • 1970-01-01
      • 2014-09-09
      相关资源
      最近更新 更多