0

I want this. Note a transparent layer on which the text (i.e Instructions) are appearing. also check the background a wooden background.

enter image description here

I m tried this but not got the desired results

 <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>

note this android:alpha="0.75" is making my all views transparent to level 0.75. i dont to want this. i just want that transparent layer.

Right know i am getting this result

enter image description here

Qadir Hussain
  • 8,721
  • 13
  • 89
  • 124

3 Answers3

2


try with:

    <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" >

You can see that: android:color="#66FF0000" // Partially transparent red

I sugest you to check this infos: Android set alpha opacity for a custom view

Android and setting alpha for (image) view alpha

Community
  • 1
  • 1
Aron
  • 1,142
  • 1
  • 14
  • 26
  • Thanks for this. it helped me but i did this android:background="##66708090". this gives me the blackish transparent color layer – Qadir Hussain Feb 20 '13 at 09:53
2

You need to set background of outermost layout to wood drawable. And set background of text view to a transparent color. Try this:

<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>
akaya
  • 1,140
  • 9
  • 27
1

xxyyyyyy

xx is your transparency level, and y's are your color.

xx max value is : ff // this is fully visible

xx min value is : 00 // this is full invisible

edit : btw, we use these code in android:background="xxyyyyyy"

Community
  • 1
  • 1
alicanbatur
  • 2,172
  • 1
  • 28
  • 36