android - How to set opacity for view(divider) and background


Keywords:android 


Question: 

I want to make background of a divider about 20% transparent, where there is a color in the background (i.e. light grey)? Below is the screenshot:

enter image description here

Then I came to this link

But not getting, how to proceed for the same for opacity. Please help


1 Answer: 

Use frame layout as a main layout .It will overlaps your layout.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
             android:background="#a8a3841a"
    >


    <LinearLayout
        android:id="@+id/wraper"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="10dp"

        android:background="#e7a3841a"
        android:orientation="horizontal">

        <View
            android:id="@+id/vwVerticalColourBar"
            android:layout_width="5dp"
            android:layout_height="match_parent"
            android:layout_gravity="center_vertical"
            android:background="@color/grey2"
            android:gravity="center_vertical"/>

        <TextView
            android:id="@+id/label"
            style="@style/item"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:layout_marginLeft="8dp"
            android:gravity="left"/>

        <TextView
            android:id="@+id/label2"
            style="@style/subitem"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:layout_marginLeft="8dp"
            android:gravity="left"/>
    </LinearLayout>

</FrameLayout>

Hope it will help you .