Abder Ramdane
Abder Ramdane

Reputation: 33

android text view(s) overlayed with button

within a linear layout i need to overlay some text views with a transparent button which fills the whole layout size (width/height). I tried with match parent layout properties but that doesn't work. Thank You for your help.

<LinearLayout
                android:id="@+id/layout1"
                android:layout_width="38dp"
                android:layout_height="match_parent"
                android:gravity="bottom"
                android:orientation="vertical" >

                <TextView
                    android:id="@+id/TVBlack"
                    android:layout_width="28dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center|bottom"
                    android:background="@color/black"
                    android:text="test"
                    android:textColor="@color/white" />

                <TextView
                    android:id="@+id/TVWhite"
                    android:layout_width="28dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center|bottom"
                    android:text="test"
                    android:textColor="@color/black" />

                <Button
                    android:id="@+id/button1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="@null"
                    android:text="Button" />

            </LinearLayout>

Upvotes: 3

Views: 2989

Answers (1)

Sam Clewlow
Sam Clewlow

Reputation: 4351

What you are trying to do is not possible with a Linear Layout, it will not overlay objects on top of each other, it will just place objects side-by-side in the order they are declared. You need to use a FrameLayout to achieve what you've described, see the docs here:

http://developer.android.com/reference/android/widget/FrameLayout.html

Upvotes: 3

Related Questions