michal
michal

Reputation: 17

add a layout on top of another layout

I'm a new programmer, I'm trying to add a winner Layout on top of another layout, however the winner Layout becomes transparent (behind the game layout) I'm not sure how to fix that.. The design of the winner Layout was copied from another layout which there I don't have this kind of problem any ideas how can I fix that?my problem

messageForWinnerLayout.setVisibility(linearLayout.VISIBLE);
<LinearLayout
    android:id="@+id/messageForWinnerLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:layout_marginLeft="40dp"

    android:layout_marginRight="40dp"
    android:layout_marginTop="100dp"

    android:background="@drawable/layout_bg"
    android:orientation="vertical"
    android:visibility="invisible">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="20dp"
        android:layout_marginTop="10dp">

        <ImageView
            android:id="@+id/closeImage"
            android:layout_width="60dp"
            android:layout_height="60dp"
            android:layout_marginLeft="250dp"
            android:onClick="ok"
            app:srcCompat="@drawable/x" />
    </RelativeLayout>

    <TextView
        android:id="@+id/haveWinnerTitle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:gravity="center_horizontal"
        android:text="We Have A Winner!"
        android:textColor="@android:color/black"
        android:textSize="18sp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/winnerMsg"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="20dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:gravity="center_horizontal"
        android:textColor="@android:color/black"
        android:textSize="18sp" />

    <Button
        android:id="@+id/closeButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="20dp"
        android:layout_marginLeft="100dp"
        android:layout_marginRight="100dp"
        android:layout_marginTop="5dp"
        android:background="@android:color/holo_blue_dark"
        android:text="Close"
        android:textColor="@android:color/white"
        android:textSize="18sp" />

</LinearLayout>

Upvotes: 0

Views: 712

Answers (1)

Sagar Vasoya
Sagar Vasoya

Reputation: 176

You can try to use Parent layout as RelativeLayout, by using RelativeLayout we can add view on Top of the another Child view.

Upvotes: 1

Related Questions