繁体   English   中英

在Android中的现有imageview上添加视图

[英]add view on existing imageview in android

我想用另一个只有黑色背景的视图覆盖现有的imageview,我希望它的大小等于imageview,但是高度不能正常工作

那是我的代码:

<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>

那就是结果:

在此处输入图片说明

<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>

在你的第二个ImageView改变你的layout_heightmatch_parent价值的layout_width。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM