2013-02-20 22 views
0

我想要這個。請注意文字(即指令)出現在其上的透明圖層。 也檢查背景木製背景。如何減少/增加布局的透明度而不是視圖

enter image description here

餘米試過,但沒有得到預期的效果

<RelativeLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:layout_margin="10dp" 
       android:alpha="0.75" > 

       <TextView 
        android:id="@+android:id/txtInstructions" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@+android:id/relImagesLogo" 
        android:layout_centerInParent="true" 
        android:lineSpacingMultiplier="1.5" 
        android:text="Lorem Ipsum is simply dummy text of 

        the printing and typesetting industry. Lorem Ipsum has been the 

        industry&apos;s standard dummy text ever since the 1500s, when an      unknown 

        printer took a galley of type and scrambled it to make a type specimen 

        book. It has survived not only five centuries, but also the leap into 

        electronic typesetting, remaining essentially unchanged. It was popularised " 
        android:textColor="@android:color/white" 
        android:textSize="14sp" /> 

       <RelativeLayout 
        android:id="@+android:id/relImagesLogo" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_centerHorizontal="true" > 

        <ImageView 
         android:id="@+android:id/imgInstructionLogo" 
         android:layout_width="30dp" 
         android:layout_height="30dp" 
         android:layout_marginRight="2dp" 
         android:src="@drawable/instruction_icon" /> 

        <ImageView 
         android:id="@+android:id/imgInstructionHeading" 
         android:layout_width="wrap_content" 
         android:layout_height="30dp" 
         android:layout_centerVertical="true" 
         android:layout_toRightOf="@+android:id/imgInstructionLogo" 
         android:src="@drawable/instruction_heading" /> 
       </RelativeLayout> 
      </RelativeLayout> 

注意到這一android:alpha="0.75"正在我所有的意見透明至0.75水平。我不想要這個。我只想要那個透明層。

權利知道我得到這個結果

enter image description here

+0

您需要創建一個可繪製的形狀並將其設置爲佈局組的背景資源 – Pragnani 2013-02-20 08:52:15

回答

2


嘗試:

<RelativeLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:layout_margin="10dp" 
     android:background="#66FF0000" > 

你可以看到: 機器人:顏色= 「#66FF0000」 //部分透明紅色

我吸收你檢查這個信息: Android set alpha opacity for a custom view

Android and setting alpha for (image) view alpha

+0

感謝您的支持。它幫助我,但我做了這個android:background =「## 66708090」。這給了我黑色透明的顏色層 – 2013-02-20 09:53:30

2

您需要設置最外層佈局木繪製的背景。 並將文本視圖的背景設置爲透明顏色。 試試這個:

<RelativeLayout xmlns:tools="http://schemas.android.com/tools" 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:layout_gravity="center_horizontal" 
android:background="#FF008833" > 

<TextView 
    android:id="@+android:id/txtInstructions" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_margin="30dp" 
    android:layout_below="@+android:id/relImagesLogo" 
    android:layout_centerInParent="true" 
    android:lineSpacingMultiplier="1.5" 
    android:background="#BB000000" 

    android:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry&apos;s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised " 
    android:textColor="@android:color/white" 
    android:textSize="14sp" /> 
</RelativeLayout> 
1

xxyyyyyy

xx是你的透明度,和y的是你的顏色。

XX最大值爲:FF //這是完全可見

XX分鐘值:00 //這是完全看不見的

編輯:順便說一句,我們在Android中使用這些代碼:背景=」 xxyyyyyy「

相關問題