1

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

这是我的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>
4

2 回答 2

3

我在用于启动页面的主题/样式中应用了透明背景,这样我就不必扭曲正在显示的图像以适应设备的屏幕尺寸。这在使用包含透明背景的 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>

然后将此主题应用于应用程序清单中的启动活动,如下所示:

    <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>
于 2013-04-10T15:57:32.190 回答
0

在我看来,您可以从布局中删除除ImageView. 所以它看起来像这样:

<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/ImageViewSplash"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        android:scaleType="centerCrop"
        android:contentDescription="@string/splashImageContentDescription" />

然后你可以在图像上使用 scaleType 直到你找到一个填满屏幕的。如果这些都不起作用,我建议提高图像文件的分辨率。

于 2013-04-10T15:31:19.157 回答