android - 如何在全屏启动画面中去除图像周围的白色边框

标签 android xml

我目前正在处理带有 ImageView 的闪屏。问题是当启动画面显示时,图像周围有一个白色边框。这样启动画面就会显示带有白色边框的图像。我想完全删除白色边框。有没有人知道这个的原因或任何建议?

这是我的 xml 代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <View android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <ImageView android:id="@+id/ImageViewSplash"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        android:scaleType="centerCrop"
        android:contentDescription="@string/splashImageContentDescription" />
</RelativeLayout>

最佳答案

我在用于初始页面的主题/样式中应用透明背景,这样我就不必扭曲显示的图像以适应设备的屏幕尺寸。这在使用包含透明背景的 PNG 文件时效果特别好。

这是我为这个“透明”主题使用的样式:

    <style name="Theme.Transparent" parent="android:Theme">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:backgroundDimEnabled">false</item>
    </style>

然后您将此主题应用到应用程序 list 中的启动 Activity ,如下所示:

    <activity
        android:name="com.masseria.homework9.SplashActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/app_name"
        android:theme="@style/Theme.Transparent" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

关于android - 如何在全屏启动画面中去除图像周围的白色边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15929813/

相关文章:

android - 启动新 Activity 时发生 TransactionTooLargeException

php - 如何将更改后的 SimpleXML 对象保存回文件?

java - 如何更改构建多个文件的版本?我的应用程式无法解决这个问题

c# - RegEx 解析 XML 文件并仅返回带有文件扩展名的 url

java - react native : error: cannot find symbol after upgrade

安卓校验rom版本

android - 使用 Ruby 向 Firebase 发送通知

android - 如何使用 Phonegap 修复 facebook android sdk 集成的以下错误

c# - Clean XML 序列化分层递归数据结构

java - setBackgroundColor 异常