0

I have LinearLayout that contains 3 ImageButtons, I want to blackout background. Also I have ImageView can I blackout it on top or no? Or i want to use something else?

How I can do it?

My XML code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center_vertical">
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="267.9dp"
        android:layout_gravity="center_horizontal"
        android:id="@+id/frameLayout1">
        <ImageView
            android:src="@drawable/fone"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerCrop"
            android:gravity="center"
            android:id="@+id/imageView1" />
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center_horizontal"
            android:id="@+id/linearLayout1"
            android:layout_marginBottom="0.0dp">
            <ImageButton
                android:src="@drawable/menu"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:id="@+id/privateButton"
                android:layout_marginRight="85.9dp"
                android:background="#00000000"
                android:layout_marginTop="11.5dp"
                android:layout_marginLeft="4.6dp" />
            <ImageButton
                android:src="@drawable/logo"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:id="@+id/logoButton"
                android:layout_marginTop="5.5dp"
                android:layout_marginLeft="4.6dp"
                android:layout_marginRight="91.7dp"
                android:background="#00000000" />
            <ImageButton
                android:src="@drawable/cart"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:id="@+id/cartButton"
                android:background="#00000000"
                android:layout_marginTop="11.5dp" />
        </LinearLayout>
    </FrameLayout>
    <LinearLayout
        android:orientation="horizontal"
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="match_parent"
        android:layout_height="142.7dp"
        android:layout_gravity="center_horizontal"
        android:id="@+id/linearLayout2"
        android:background="#ffffff">
        <Button
            android:text="Суші"
            android:layout_width="185.8dp"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:id="@+id/button1"
            android:background="@drawable/sushi"
            android:textColor="#ffffff"
            android:textSize="20sp"
            android:textStyle="bold"
             android:layout_marginRight="1dp"
            android:layout_marginBottom="1dp" />
        <Button
            android:text="Роли"
            android:layout_width="178.8dp"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:id="@+id/button2"
            android:background="@drawable/rolli"
            android:textColor="#ffffff"
            android:textSize="20sp"
            android:textStyle="bold"
            android:layout_marginBottom="1dp" />
    </LinearLayout>
    <LinearLayout
        android:orientation="horizontal"
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="match_parent"
        android:layout_gravity="center_horizontal"
        android:layout_height="142.7dp"

        android:id="@+id/linearLayout3"
        android:background="#ffffff">
        <Button
            android:text="Сети"
            android:layout_width="185.8dp"
            android:layout_height="match_parent"
            android:gravity="center"
            android:id="@+id/button3"
            android:background="@drawable/sets"
            android:textColor="#ffffff"
            android:textSize="20sp"
            android:textStyle="bold"
             android:layout_marginRight="1dp" />
        <Button
            android:text="Холодні Закуски"
            android:gravity="center"
            android:layout_width="178.8dp"
            android:layout_height="match_parent"
            android:id="@+id/button4"
            android:background="@drawable/holodni"

            android:textColor="#ffffff"
            android:textSize="20sp"
            android:textStyle="bold" />
    </LinearLayout>
    <LinearLayout
        android:orientation="horizontal"
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center_horizontal"
        android:id="@+id/linearLayout4"
        android:layout_marginLeft="0.0dp">
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="center_horizontal"
            android:background="#f2565c"
            android:id="@+id/linearLayout5">
            <ImageButton
                android:src="@drawable/back"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:id="@+id/previousButton"
                android:layout_marginRight="137.8dp"
                android:background="#00000000"
                android:layout_marginTop="17.8dp"
                android:clickable="true"
                android:layout_marginLeft="13.8dp" />
            <ImageButton
                android:src="@drawable/home"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:id="@+id/homeButton"
                android:layout_marginRight="121.8dp"
                android:background="#00000000"
                android:layout_marginTop="13.6dp"
                android:clickable="true" />
            <ImageButton
                android:src="@drawable/next"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:id="@+id/nextButton"
                android:layout_marginLeft="0.0dp"
                android:background="#00000000"
                android:layout_marginTop="17.8dp"

                android:clickable="true" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

Thank's for help!

ase
  • 13,231
  • 4
  • 34
  • 46

1 Answers1

0

This is how you put semitransparent black color. enter background attribute like this:

 <LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:background="#AARRGGBB"
        android:layout_gravity="center_horizontal"
        android:id="@+id/linearLayout1"
        android:layout_marginBottom="0.0dp">

For more info how to get semi-transparent color see this question and answer. Android Dialog Semi-Transparent

Hope it helps!

Community
  • 1
  • 1
Umair
  • 6,366
  • 15
  • 42
  • 50