0

I want to cover existing imageview with another view which just has black background and i want its size to be equal to the imageview but the height doesn't work properly

That's my code :

<RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#000" >

                    <ImageView
                        android:id="@+id/feedImage"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:adjustViewBounds="true"
                        android:scaleType="fitXY"
                        android:src="@drawable/cover" />

                    <RelativeLayout
                        android:id="@+id/playBackground"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_centerInParent="true"                        
                        android:background="#75000000" >

                        <ImageView
                            android:id="@+id/playIcon"
                            android:layout_width="110dp"
                            android:layout_height="110dp"
                            android:layout_centerInParent="true"
                            android:adjustViewBounds="true"
                            android:scaleType="fitXY"
                            android:src="@drawable/play" />
                    </RelativeLayout>
                </RelativeLayout>

That's the result :

enter image description here

eng.ahmed
  • 905
  • 4
  • 16
  • 38

2 Answers2

1
<FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#000" >

                <ImageView
                    android:id="@+id/feedImage"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:adjustViewBounds="true"
                    android:scaleType="fitXY"
                    android:src="@drawable/cover" />

                <RelativeLayout
                    android:id="@+id/playBackground"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_centerInParent="true"                        
                    android:background="#75000000" >

                    <ImageView
                        android:id="@+id/playIcon"
                        android:layout_width="110dp"
                        android:layout_height="110dp"
                        android:layout_centerInParent="true"
                        android:adjustViewBounds="true"
                        android:scaleType="fitXY"
                        android:src="@drawable/play" />
                </RelativeLayout>
            </FrameLayout>
Preethi Rao
  • 5,117
  • 1
  • 16
  • 29
0

in your second ImageView change your layout_height and your layout_width by match_parent value.

Fakher
  • 2,098
  • 3
  • 29
  • 45