android开发有多个父控件存在时这个控件中的ImageView在其他控件显示不出来的问题

原因:原因是不同的控件高低层次不同,遮挡了显示
解决方法:将android:clipChildren置为"false"。android:clipChildren=“false”
有多个父控件存在时全把android:clipChildren置为"false"
例如(带星号部分):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@mipmap/remote_background">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipChildren="false"//**************************************
        android:orientation="vertical">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1.7">

        </RelativeLayout>
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:clipChildren="false"//**************************************
            android:layout_weight="1">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:clipChildren="false"//**************************************
                android:orientation="horizontal">
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1">
                    <ImageView
                        android:id="@+id/position"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:clipChildren="false"//**************************************
                        android:background="@mipmap/remote_speed_hand"/>
                </RelativeLayout>
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1.02">

                </RelativeLayout>
            </LinearLayout>
        </RelativeLayout>
    </LinearLayout>
    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="ddd"/>
</RelativeLayout>
原创文章 81 获赞 48 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_15181569/article/details/103645639