Android 布局\框架布局中的重力和z顺序不工作

Android 布局\框架布局中的重力和z顺序不工作,android,xml,android-layout,Android,Xml,Android Layout,我是新来的,所以请温柔一点: 我正在将最新的应用程序视图移植到现有的SystemUI中,因此我使用的是xml和smali,而不是Java。但是,我的问题与布局XML有关,所以可以在这里提问。具体地说,我正在将新的Android L风格的最新版本从ParanoidAndroid移植到我们的SystemUI中,因此它是新的cardstack视图。这是我的状态栏最近的面板cardstack.xml,它设置了最近的视图并包含了包含实际cardstack的滚动视图: <?xml version="1

我是新来的,所以请温柔一点:

我正在将最新的应用程序视图移植到现有的SystemUI中,因此我使用的是xml和smali,而不是Java。但是,我的问题与布局XML有关,所以可以在这里提问。具体地说,我正在将新的Android L风格的最新版本从ParanoidAndroid移植到我们的SystemUI中,因此它是新的cardstack视图。这是我的状态栏最近的面板cardstack.xml,它设置了最近的视图并包含了包含实际cardstack的滚动视图:

<?xml version="1.0" encoding="utf-8"?>
<com.android.systemui.recent.RecentsPanelView android:id="@id/recents_root" android:layout_width="fill_parent" android:layout_height="fill_parent" android:foreground="@drawable/bg_protect_transparent" systemui:recentItemLayout="@layout/status_bar_recent_item"
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
    <FrameLayout android:id="@id/recents_bg_protect" android:background="@drawable/status_bar_recents_background_cardstack" android:fitsSystemWindows="true" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentBottom="true" android:clipChildren="false">
        <com.android.systemui.recent.RecentsVerticalScrollView android:layout_gravity="start|bottom|center" android:id="@id/recents_container" android:scrollbars="none" android:fadingEdge="vertical" android:fadingEdgeLength="@dimen/status_bar_recents_scroll_fading_edge_length" android:clipChildren="false" android:clipToPadding="false" android:layout_width="fill_parent" android:layout_height="wrap_content" android:stackFromBottom="true" android:divider="@null" android:layout_marginEnd="0.0dip">
            <LinearLayout android:orientation="vertical" android:id="@id/recents_linear_layout" android:fitsSystemWindows="true" android:clipChildren="false" android:clipToPadding="false" android:layout_width="fill_parent" android:layout_height="wrap_content" />
        </com.android.systemui.recent.RecentsVerticalScrollView>
        <include android:id="@id/recents_no_apps" android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="fill_parent" layout="@layout/status_bar_no_recent_apps" />
        <ImageView android:layout_gravity="top|right|center" android:id="@id/recents_clear" android:clickable="true" android:layout_width="50.0dip" android:layout_height="50.0dip" android:src="@drawable/ic_recents_clear" android:scaleType="center" />
    </FrameLayout>
</com.android.systemui.recent.RecentsPanelView>
这是一个布局,它定义了堆栈中的每一张卡片,以防它与我的问题有关:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@id/recent_item" android:padding="@dimen/status_bar_recents_card_margin" android:clipChildren="true" android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout android:id="@id/app_thumbnail" android:background="@drawable/status_bar_recent_card_shadow" android:layout_width="fill_parent" android:layout_height="fill_parent">
    <ImageView android:id="@id/app_thumbnail_image" android:paddingTop="@dimen/status_bar_recents_app_color_bar_height" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="centerCrop" />
    <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content">
        <LinearLayout android:orientation="horizontal" android:id="@id/app_top_colored_bar" android:background="@color/status_bar_recents_app_bar_color" android:layout_width="fill_parent" android:layout_height="@dimen/status_bar_recents_app_color_bar_height">
            <ImageView android:layout_gravity="center_vertical" android:id="@id/app_icon" android:layout_width="wrap_content" android:layout_height="@dimen/status_bar_recents_app_color_bar_icon_size" android:layout_margin="@dimen/status_bar_recents_app_color_bar_icon_margin" android:scaleType="centerInside" android:adjustViewBounds="true" android:maxWidth="@dimen/status_bar_recents_app_icon_max_width" android:maxHeight="@dimen/status_bar_recents_app_icon_max_height" android:layout_weight="0.0" />
            <TextView android:textSize="@dimen/status_bar_recents_app_color_bar_label_size" android:textColor="@color/status_bar_recents_app_label_color_dark" android:ellipsize="marquee" android:layout_gravity="center_vertical" android:id="@id/app_label" android:fadingEdge="horizontal" android:fadingEdgeLength="@dimen/status_bar_recents_text_fading_edge_length" android:layout_width="@dimen/status_bar_recents_app_label_width" android:layout_height="wrap_content" android:scrollHorizontally="true" android:singleLine="true" android:layout_weight="1.0" android:importantForAccessibility="no" android:textAlignment="viewStart" android:layout_marginStart="@dimen/status_bar_recents_app_label_left_margin" android:layout_toEndOf="@id/app_icon" android:layout_alignParentStart="true" />
        </LinearLayout>
        <ImageView android:id="@id/app_thumbnail_border" android:background="@drawable/status_bar_recent_card_border" android:layout_width="fill_parent" android:layout_height="wrap_content" />
    </RelativeLayout>
</RelativeLayout>
<View android:id="@id/recents_callout_line" android:visibility="gone" android:layout_width="0.0dip" android:layout_height="0.0dip" />
<TextView android:id="@id/app_description" android:visibility="gone" android:layout_width="0.0dip" android:layout_height="0.0dip" />
</RelativeLayout>
我有两个问题。首先,在第一个布局中设置为“最近清除图像”视图的“全部清除”按钮不会出现在卡叠上方,而是在卡叠后面被遮挡,因此无法单击。为什么定义项目的Z顺序没有被识别,有没有办法将其强制到前面

图像清除所有按钮右下角被cardstack遮挡-

其次,我添加了通过对卡片宽度应用比例因子以编程方式缩小卡片堆栈的功能。然而,当我减小卡片尺寸时,我想使堆栈居中,但无论我对两种布局中的任何或所有元素应用何种布局,卡片堆栈都保持与最终父级左侧对齐(减去填充)。如何将缩小后的卡置于中心位置


图像缩小后的cardstack在父级中仍然左对齐-

如果使用eclipse,请首先单击ctrl+shift+f。这将以可读的格式布局xml—不使用Eclipse作为AIK—您无法反编译现有apk并将其导入Eclipse,因此只需在Ownery editor Studio、Notepad++中使用反编译文件即可,etcAnother Think—由布局xml中声明的顺序定义的Z顺序是否会被例如在onFinishInflate中以编程方式声明元素的顺序所取代?是的。元素的顺序是从下到上的Z顺序,也许我问得不太好。我知道布局xml中最后声明的项将是视图堆栈中的最顶层。我遇到的问题是,上面第一个xml中的clear all按钮recents_clear总是被卡堆栈遮挡,卡堆栈保存在recents_容器中,该容器在布局中的recents_clear之前定义,因此应该以Z顺序显示在clear all按钮之前。因此,我问代码中是否有东西可以取代XMLZ顺序。