Splash 屏幕图片小尺寸安卓

huangapple go评论84阅读模式
英文:

Splash screen image small android

问题

**drawable/launch_background.xml**

<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/splash_background" />

    <!-- You can insert your own image assets here -->
    <item>
        <bitmap
            android:gravity="center"
            android:src="@mipmap/ic_launcher" />
    </item>
    <item>
        <bitmap
            android:gravity="bottom"
            android:src="@mipmap/bottom_launcher" />
    </item>
</layer-list>

**AndroidManifest**

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com...">
    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="..."
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>
英文:

I am using flutter to create an android app, the splash screen image is small, please how do i fix it

drawable/launch_background.xml

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;!-- Modify this file to customize your launch splash screen --&gt;
&lt;layer-list xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;
    &lt;item android:drawable=&quot;@color/splash_background&quot; /&gt;

    &lt;!-- You can insert your own image assets here --&gt;
    &lt;item&gt;
        &lt;bitmap
            android:gravity=&quot;center&quot;
            android:src=&quot;@mipmap/ic_launcher&quot; /&gt;
    &lt;/item&gt;
        &lt;item&gt;
        &lt;bitmap
            android:gravity=&quot;bottom&quot;
            android:src=&quot;@mipmap/bottom_launcher&quot; /&gt;
    &lt;/item&gt;
&lt;/layer-list&gt;

<!-- end snippet -->

AndroidManifest

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    package=&quot;com...&quot;&gt;
    &lt;!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. --&gt;
    &lt;application
        android:name=&quot;io.flutter.app.FlutterApplication&quot;
        android:label=&quot;...&quot;
        android:icon=&quot;@mipmap/ic_launcher&quot;&gt;
        &lt;activity
            android:name=&quot;.MainActivity&quot;
            android:launchMode=&quot;singleTop&quot;
            android:theme=&quot;@style/LaunchTheme&quot;
            android:configChanges=&quot;orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode&quot;
            android:hardwareAccelerated=&quot;true&quot;
            android:windowSoftInputMode=&quot;adjustResize&quot;&gt;
            &lt;intent-filter&gt;
                &lt;action android:name=&quot;android.intent.action.MAIN&quot;/&gt;
                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot;/&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
        &lt;!-- Don&#39;t delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --&gt;
        &lt;meta-data
            android:name=&quot;flutterEmbedding&quot;
            android:value=&quot;2&quot; /&gt;
    &lt;/application&gt;
&lt;/manifest&gt;

<!-- end snippet -->

What may be making the image small, the bottom image disappears and just shows that small icon, I've put the correct image and sizes in minmap-hdpi, mdpi, etc

Splash 屏幕图片小尺寸安卓

Splash 屏幕图片小尺寸安卓

答案1

得分: 1

以下是翻译好的内容:

"在你分享闪屏活动布局(.xml文件)时将会很有帮助。

我认为,如果你在两个不同的层上工作,控制“闪屏图标”的大小会更容易。为背景创建一个可绘制资源,为“标志”本身创建另一个可绘制资源。

在你的闪屏活动布局中,你可以使用背景图像作为你的视图组(LinearLayout,ConstraintLayout等)的背景,并将标志居中放置在其上。你可以对标志的宽度和高度使用“wrap_content”,或者以dp为单位设置固定大小。这会导致两种情况:

如果你为标志使用固定大小,图像在较大的设备上可能会看起来像素化。

我建议在标志上使用“wrap_content”,但在较大的设备上,你的图像会显得很小(就像屏幕截图上一样)。为了避免这种情况,你应该提供不同大小的标志,并将它们放在以下文件夹中:

  • drawable - 默认的图像资源文件夹
  • drawable-mdpi
  • drawable-hdpi
  • drawable-xdpi
  • drawable-xxdpi
  • drawable-xxxdpi

较大的设备将使用xxxdpi文件夹
较小的设备将使用mdpi

你可以一次生成所有这些图像大小,https://appicon.co/#image-sets 这里可以生成。

如果设备找不到适用于其尺寸的drawable-...dpi文件夹,它将使用默认文件夹中的图像。
(你可以在这里查看更多信息:https://developer.android.com/training/multiscreen/screendensities

你的闪屏布局应该类似于以下内容:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:gravity="center"
    android:background="YOUR BACKGROUND DRAWABLE HERE"
    android:layout_height="match_parent">

    <ImageView
        android:layout_width="wrap_content"
        android:src="YOUR LOGO DRAWABLE HERE"
        android:layout_height="wrap_content"/>

</LinearLayout>

<details>
<summary>英文:</summary>

Well, It would be helpful if you share the splash activity layout (the .xml file).

I believe it would be easier to control de &quot;splash icon&quot; size if you work on two different layer. Have a drawable for the background and another drawable for the &quot;logo&quot; itself.

On you splash activity layout you can use the background image as the background of your viewgroup (LinearLayout, ConstraintLayout...) and center you logo above it. You can use &quot;wrap_content&quot; for width and height of the logo, or set a fixed size in dp. It leads us to two situations:

If you use a fixed size for your logo, the image may look pixelized on bigger devices. 

I recommend using &quot;wrap_content&quot; on the logo, but your image will look small on bigger devices (as it is on the screenshot). To avoid this, you should provide different sizes of the logo and put them on the following folders:
- drawable - the default image asset folder
- drawable-mdpi
- drawable-hdpi
- drawable-xdpi
- drawable-xxdpi
- drawable-xxxdpi

Larger devices will use xxxdpi folder
Smaller devices will user mdpi

You can generate all these images size at once here:
[https://appicon.co/#image-sets][1]

If the device can&#39;t find the drawable-...dpi that&#39;s recommended for its size, It will use the image from the default folder.
(You can check more info about this here: [https://developer.android.com/training/multiscreen/screendensities][2] )

You splash layout should be something like this:

        &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
    &lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
        android:layout_width=&quot;match_parent&quot;
        android:gravity=&quot;center&quot;
        android:background=&quot;YOUR BACKGROUND DRAWABLE HERE&quot;
        android:layout_height=&quot;match_parent&quot;&gt;
    
        &lt;ImageView
            android:layout_width=&quot;wrap_content&quot;
            android:src=&quot;YOUR LOGO DRAWABLE HERE&quot;
            android:layout_height=&quot;wrap_content&quot;/&gt;
    
    &lt;/LinearLayout&gt;


  [1]: https://appicon.co/#image-sets
  [2]: https://developer.android.com/training/multiscreen/screendensities

</details>



huangapple
  • 本文由 发表于 2020年4月6日 07:33:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/61050868.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定