2013-08-31 43 views
0

我想在圖像上方顯示一些信息(TextView)。當我在圖像上顯示Textview時,背景圖像會干擾文本。所以我想使背景圖像(淡入淡出),以便它不會干擾TextView。我怎樣才能做到這一點?需要在背景圖像上方顯示一些信息

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".MainActivity" > 

<ImageView 
    android:id="@+id/background" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true" 
    android:padding="20dp" 
    android:scaleType="center" 
    android:src="@drawable/cor" /> 

<TextView 
    android:id="@+id/info" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_alignTop="@+id/background" 
    android:layout_marginLeft="66dp" 
    android:layout_marginTop="26dp" 
    android:text="Some information" 
    android:textAppearance="?android:attr/textAppearanceLarge" /> 

+0

你可以發佈您的代碼,以便它可以在圖助陣實際問題 –

回答

0

使用setalpha方法將ImageView的,使外觀沉悶。低於API級別

設置阿爾法8

AlphaAnimation anim = new AlphaAnimation(0.4f, 0.4f); 
anim.setDuration(50); 
anim.setFillEnabled(true); 
anim.setFillAfter(true); 
<view>.startAnimation(anim); 
+0

setAplha(浮動)在新的API加入,但我最小的SDK版本是8.是否有任何其他方法??? – Rage

+0

在java代碼中應用alpha動畫 –

+0

非常感謝。整天都在困擾我:) – Rage