0

I want that my relative layout be transparent. I have relative layout who contains linearlayout and two images. Color that I use now is #878787, but how can I set that whole layout to transparent. Is it possible in android or not. Does anyone have the problem of this type. Thank you very much

<RelativeLayout
        android:id="@+id/linearLayout4"
        android:layout_width="match_parent"
        android:layout_height="?android:attr/actionBarSize"
        android:layout_alignParentBottom="true"
        android:background="#878787"
        android:orientation="horizontal"
        android:weightSum="100" >

        <ImageView
            android:id="@+id/previousButton"
            android:layout_width="50dp"
            android:layout_height="wrap_content"
            android:layout_marginEnd="-7dp"
            android:layout_marginLeft="-7dp"
            android:layout_marginRight="-7dp"
            android:layout_marginStart="-7dp"
            android:contentDescription="@string/autoskola_imageView"
            android:soundEffectsEnabled="false"
            android:src="@drawable/ikona_lijevo" />

        <ImageView
            android:id="@+id/nextButton"
            android:layout_width="50dp"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_marginEnd="-7dp"
            android:layout_marginLeft="-7dp"
            android:layout_marginRight="-7dp"
            android:layout_marginStart="-7dp"
            android:contentDescription="@string/autoskola_imageView"
            android:soundEffectsEnabled="false"
            android:src="@drawable/ikona_desno" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_centerHorizontal="true" >

            <ImageView
                android:id="@+id/povecaloButtonPitanja"
                android:layout_width="100dp"
                android:layout_height="match_parent"
                android:layout_marginLeft="5dp"
                android:layout_marginStart="5dp"
                android:contentDescription="@string/autoskola_imageView"
                android:soundEffectsEnabled="false" />

            <ImageView
                android:id="@+id/informacijeButton"
                android:layout_width="100dp"
                android:layout_height="match_parent"
                android:layout_marginEnd="5dp"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:layout_marginStart="5dp"
                android:contentDescription="@string/autoskola_imageView"
                android:soundEffectsEnabled="false"
                android:src="@drawable/gumb_informacije" />

            <ImageView
                android:id="@+id/odgovoriButton"
                android:layout_width="100dp"
                android:layout_height="match_parent"
                android:layout_marginLeft="5dp"
                android:layout_marginStart="5dp"
                android:contentDescription="@string/autoskola_imageView"
                android:soundEffectsEnabled="false"
                android:src="@drawable/gumb_odgovori" />
        </LinearLayout>
    </RelativeLayout>
marko kurt
  • 205
  • 4
  • 12

3 Answers3

1

Just set the color to "#00000000". The last 6 hex digits don't matter. the first two sets the alpha at 0. Or use android's built in transparent color. Or even @null works I think.

Miao Liu
  • 440
  • 4
  • 9
1

Use android:alpha="0" // Assign your alpha value between 0 to 1. 0 for complete transparent.

 <RelativeLayout
            android:id="@+id/linearLayout4"
            android:layout_width="match_parent"
            android:layout_height="?android:attr/actionBarSize"
            android:layout_alignParentBottom="true"
            android:background="#878787"
            android:alpha="0" 
            android:orientation="horizontal"
            android:weightSum="100" >

            <ImageView
                android:id="@+id/previousButton"
                android:layout_width="50dp"
                android:layout_height="wrap_content"
                android:layout_marginEnd="-7dp"
                android:layout_marginLeft="-7dp"
                android:layout_marginRight="-7dp"
                android:layout_marginStart="-7dp"
                android:contentDescription="@string/autoskola_imageView"
                android:soundEffectsEnabled="false"
                android:src="@drawable/ikona_lijevo" />

            <ImageView
                android:id="@+id/nextButton"
                android:layout_width="50dp"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:layout_marginEnd="-7dp"
                android:layout_marginLeft="-7dp"
                android:layout_marginRight="-7dp"
                android:layout_marginStart="-7dp"
                android:contentDescription="@string/autoskola_imageView"
                android:soundEffectsEnabled="false"
                android:src="@drawable/ikona_desno" />

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_centerHorizontal="true" >

                <ImageView
                    android:id="@+id/povecaloButtonPitanja"
                    android:layout_width="100dp"
                    android:layout_height="match_parent"
                    android:layout_marginLeft="5dp"
                    android:layout_marginStart="5dp"
                    android:contentDescription="@string/autoskola_imageView"
                    android:soundEffectsEnabled="false" />

                <ImageView
                    android:id="@+id/informacijeButton"
                    android:layout_width="100dp"
                    android:layout_height="match_parent"
                    android:layout_marginEnd="5dp"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="5dp"
                    android:layout_marginStart="5dp"
                    android:contentDescription="@string/autoskola_imageView"
                    android:soundEffectsEnabled="false"
                    android:src="@drawable/gumb_informacije" />

                <ImageView
                    android:id="@+id/odgovoriButton"
                    android:layout_width="100dp"
                    android:layout_height="match_parent"
                    android:layout_marginLeft="5dp"
                    android:layout_marginStart="5dp"
                    android:contentDescription="@string/autoskola_imageView"
                    android:soundEffectsEnabled="false"
                    android:src="@drawable/gumb_odgovori" />
            </LinearLayout>
        </RelativeLayout>
Bhavin Shah
  • 361
  • 4
  • 11
0

Here this link may help you to understand transparency % in hex colors, the first two digits are procent of transparency and the others are your desired color. ->> https://stackoverflow.com/a/17239853/2971619

Community
  • 1
  • 1
Kristiyan Varbanov
  • 2,439
  • 2
  • 17
  • 37