2016-07-29 46 views
1

我有以下XML繪製拉伸:中心繪製在奇巧

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 

    <item android:drawable="@android:color/white" /> 
    <item android:drawable="@drawable/previous_step" android:gravity="center"/> 

</layer-list> 

這是它的外觀在Android上5:

enter image description here

然而,這是Android 4.4 totall拉伸:

enter image description here

什麼可以做到解決它在Android 4.4?請注意,我只能使用drawable xml,因爲這是background of the splash

+0

您確定在兩種情況下都加載了相同的佈局文件嗎? – Shaishav

+0

給你顯示xml文件 – Vickyexpert

+0

@Shaishav是的,我相信。 – WonderCsabo

回答

0

如果您訪問此xml只是修復其高度和寬度,然後作爲背景進行訪問,這將修復您的錯誤。例如:

<ImageView 
    android:id="@+id/splash_image" 
    android:layout_width="@dimen/splash_width" 
    android:layout_height="@dimen/splash_height" 
    android:layout_gravity="center" 
    android:background="@drawable/drawable_image" 
    android:scaleType="fitCenter" /> 
+0

這不是一個可繪製的xml文件,這是我不能使用的佈局。 – WonderCsabo

+0

你不能以你的方式獲取所有東西,但我認爲這將有助於在你的項目中添加一些變化,例如見下面的代碼根據您的要求給出** splash_size **值 _ <項機器人:抽拉= 」@繪製/ previous_step「 \t \t機器人:比重= 」中心「 \t **機器人:左= 」@捫/ splash_size「 機器人:右=」 @ dimen/splash_size「 android:bottom =」@ dimen/splash_size「 android:top =」@ dimen/splash_size「/> ** _ –