2013-10-30 62 views
1

我有2張圖片:bg_Imagebox_image如何將src設置爲android中的relativeLayout?

我想用bg_Image爲背景。

我已經使用了android RelativeLayout,但是當我將它設置爲背景時 - 它跨越了太多。

我希望它保持原來的bg_Image大小。我無法將RelativeLayout src設置爲bg_Image

另一件事是box_imagebg_Image

一個孩子,因爲我想用動畫box_image相對移動其父大小

這就是爲什麼我想他們是父子關係。

<?xml version="1.0" encoding="utf-8"?> 
<set 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:interpolator="@android:anim/accelerate_interpolator"> 
    <translate 
android:fromXDelta="-100%p" 
    android:toXDelta="0%" 
    android:duration="600"> 

    </translate> 
</set> 

我該怎麼做?

回答

0

設置相對佈局高度和寬度以包裝內容並設置背景。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="your background image"> 
</Relativelayout> 

或給定相對佈局的高度和寬度。

希望它會有所幫助。

0

設置寬度和高度以包裝內容。設置包裝內容時需要圖像的原始尺寸。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@drawable/bg_Image"> 

    </Relativelayout> 

希望這將有助於.. :)

相關問題