-2

enter image description here

This is one LinearLayout. I set this layout alpha to 0.6.

enter image description here

I want to set transparency only background, But it set inner values too.. Is there any solution to solve this problem?

<LinearLayout
        android:alpha="0.6"
        android:background="@mipmap/ic_launcher"
        android:layout_width="match_parent"
        android:layout_height="250dp">
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="80dp"
            android:layout_alignParentTop="true"
            android:layout_alignParentStart="true"
            android:background="#33B99F">

            <Button
                android:id="@+id/goBackButton"
                android:textSize="15dp"
                android:textColor="#FFFFFF"
                android:background="@drawable/back"
                android:layout_width="25dp"
                android:layout_height="25dp"
                android:layout_marginTop="30dp"
                android:layout_marginLeft="10dp" />

            <TextView
                android:text="register(1/3)"
                android:textSize="20dp"
                android:textStyle="bold"
                android:textColor="#FFFFFF"
                android:textAlignment="center"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginRight="30dp"
                android:id="@+id/textView" />
        </LinearLayout>
    </LinearLayout>

Here is my code.

SunSpike
  • 31
  • 5
  • @OussemaAroua Linearlayout's background is android Image. I set the android image to the background, and I want to put the value alpha "1.0". but because of parent's alpha is "0.6". so inner value's alpha is 0.6 too. I want to solve this error. – SunSpike Nov 01 '17 at 11:05
  • you need to set the background to transparency not the linearlayout it self – Oussema Aroua Nov 01 '17 at 11:17
  • but linearLayout's background is `@mipmap/ic_luncher`. Where to put #80000000? – SunSpike Nov 01 '17 at 11:45

4 Answers4

1

Try to use "#AAFFFFFF" on your layout background, or something like that. The first two values (AA in this case) represent the transparency. For more information take a look at the Color documentation.

gbruscatto
  • 686
  • 7
  • 21
  • It doesn't work.. – SunSpike Nov 01 '17 at 11:43
  • If you want to keep the image, you can use a relative layout instead and set the background in it as I said, and then use a ImageView with `android:layout_width="match_parent"` and `android:layout_height="match_parent"` to show the image. – gbruscatto Nov 01 '17 at 12:08
0

Set background as #80000000. Hope it works

0

You can try this

<LinearLayout android:alpha="0.6"
android:background="@mipmap/ic_launcher"
android:layout_width="match_parent"
android:layout_height="250dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="80dp"
    android:layout_alignParentTop="true"
    android:layout_alignParentStart="true"
    android:background="#8033B99F">

    <Button
        android:id="@+id/goBackButton"
        android:textSize="15dp"
        android:textColor="#FFFFFF"
        android:background="@drawable/back"
        android:layout_width="25dp"
        android:layout_height="25dp"
        android:layout_marginTop="30dp"
        android:layout_marginLeft="10dp" />

    <TextView
        android:text="register(1/3)"
        android:textSize="20dp"
        android:textStyle="bold"
        android:textColor="#FFFFFF"
        android:textAlignment="center"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginRight="30dp"
        android:id="@+id/textView" />
</LinearLayout>

Ratilal Chopda
  • 4,162
  • 4
  • 18
  • 31
  • It doesn't work. I want to make this color thicker than now, But #8033B99F is more lightly than now. – SunSpike Nov 01 '17 at 11:42
  • you have require more transparent 100% — FF 95% — F2 90% — E6 85% — D9 80% — CC 75% — BF 70% — B3 65% — A6 60% — 99 55% — 8C 50% — 80 45% — 73 40% — 66 35% — 59 30% — 4D 25% — 40 20% — 33 15% — 26 10% — 1A 5% — 0D 0% — 00 – Ratilal Chopda Nov 01 '17 at 11:44
  • #8033B99F this is 50% transparent bro – Ratilal Chopda Nov 01 '17 at 11:46
  • Oh. I mistake it. Thanks. But still can't solve this problem. I put Linearlayout inside a LinearLayout. but because of parent LinearLayout's alpha is 0.6, so child LinearLayout's alpha is also 0.6. I want to set alpha 1.0 of child LinearLayout. and I want to set parent LinearLayout's alpha to 0.6 – SunSpike Nov 01 '17 at 11:51
  • Sorry... I'm not fluent in English... – SunSpike Nov 01 '17 at 11:51
  • @SunSpike Did you get answer for this? I have parent LinearLayout and 2 LL inside it. I want to set transparent to one layout – Rohan Aug 26 '23 at 00:09
0

dont set alpha for linearlayour because it contains another element so alpha will be applied to all the alement inside of linear layout so try to set background of linear layout onlu like eg. android:background="#00ffffff" to make any colour transperent add 00 ahead of any hex code

Vinesh Chauhan
  • 1,288
  • 11
  • 27