提升孩子时,Android FrameLayout z-index问题

rof*_*ofl 3 android android-layout android-view android-framelayout

我有以下Android XML布局文件:

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginEnd="@dimen/AutoComplete_marginSides"
        android:layout_marginRight="@dimen/AutoComplete_marginSides"
        android:layout_marginTop="@dimen/AutoComplete_marginTopBottom"
        android:layout_marginBottom="@dimen/AutoComplete_marginTopBottom"
        android:layout_marginLeft="@dimen/AutoComplete_marginSides"
        android:layout_marginStart="@dimen/AutoComplete_marginSides"
        android:id="@+id/autoCompleteLayout" >

        <MyPackage.maps.DelayAutoCompleteTextView
            android:id="@+id/geoAutoComplete"
            android:layout_margin="@dimen/AutoCompleteTextView_layoutMargin"
            android:layout_width="match_parent"
            android:layout_height="@dimen/AutoCompleteTextView_height"
            android:layout_gravity="center"
            android:gravity="start|center_vertical"
            android:inputType="textCapSentences"
            android:background="@color/white"
            android:paddingLeft="@dimen/AutoCompleteTextView_padding"
            android:paddingRight="@dimen/AutoCompleteTextView_padding"
            android:dropDownWidth="fill_parent"
            android:textSize="@dimen/AutoCompleteTextView_fontSize"
            android:hint="@string/search_map"
            android:elevation="2dp"
            android:singleLine="true"
            android:maxLength="30"/>

        <ImageView
            android:id="@+id/geoAutoCompleteClear"
            android:layout_gravity="center_vertical|end"
            android:contentDescription="@string/search_map_clear"
            android:layout_marginEnd="@dimen/AutoCompleteTextView_clearIconMargins"
            android:layout_marginRight="@dimen/AutoCompleteTextView_clearIconMargins"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_clear"/>

    </FrameLayout>
Run Code Online (Sandbox Code Playgroud)

FrameLayout布局内的RelativeLayout(我没有表现出高于)。这FrameLayout只是文本视图,末尾带有叉号以删除文本。

问题是,当我添加android:elevationTextViewImageView云背后的TextView,尽管它不应该,因为我定义后TextView本身。据我所知,子序列决定了如何显示组件。但是,当我elevation从中删除时TextViewImageView显示正确。

我在这里想念什么吗?这是什么原因呢?

cry*_*son 5

android:elevation覆盖FrameLayout或RelativeLayout中典型的z索引概念。您所看到的是正确的行为。您可以将ImageView的高程设置为“ 3dp”,这将为您提供预期的排序。