2013-04-10 83 views
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> 
+2

爲什麼你有一個在佈局中的任意視圖? – 2013-04-10 15:16:47

回答

2

我在用於我的初始頁面的主題/樣式中應用透明背景,這樣我就不必扭曲正在顯示的圖像以適應設備的屏幕大小。這在使用包含透明背景的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> 
+0

我試圖使相關佈局的背景顏色和透明的,它仍然不起作用。 – 2013-04-10 21:01:39

+0

你如何將圖像加載到ImageView中? – HeatfanJohn 2013-04-11 01:50:11

+0

我用代碼載入img.setImageReosource(R.drawable.image)。 – 2013-04-11 09:51:02

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。如果這些都不起作用,我會建議增加圖像文件的分辨率。

+0

我已經試過你的方式,但我沒有成功。 – 2013-04-11 09:54:36

+0

啊,你可能需要將adjustViewBounds設置爲false。也許它正在縮小視圖的大小。 – drewhannay 2013-04-11 14:11:43

+0

問題已解決。由於我使用對話框來顯示啓動畫面,所以我需要將它設置爲對話框,而不是實際的屏幕 – 2013-04-12 21:10:26