Android 如何将ImageView置于透明状态栏下

Android 如何将ImageView置于透明状态栏下,android,xml,statusbar,transparent,android-framelayout,Android,Xml,Statusbar,Transparent,Android Framelayout,在下面的图像中,我试图将ImageView置于状态栏下。但这并没有发生 我继续(这个问题)并尝试实现相同的功能,但它不起作用。 活动的xml布局是 <?xml version="1.0" encoding="utf-8"?> <FrameLayout android:layout_height="match_parent" android:layout_width="match_parent" android:fitsSystemWindows="true" xmlns:

在下面的图像中,我试图将ImageView置于状态栏下。但这并没有发生

我继续(这个问题)并尝试实现相同的功能,但它不起作用。

活动的xml布局是

<?xml version="1.0" encoding="utf-8"?>
 <FrameLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="@+id/category_layout_top"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<ImageView
    android:fitsSystemWindows="true"
    android:layout_width="390dp"
    android:layout_height="390dp"
    android:id="@+id/category_Image_View"/>


    <android.support.v7.widget.Toolbar
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/def_toolbar"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:minHeight="?attr/actionBarSize"
        android:background="#00FFFFFF"
        android:layout_alignParentTop="true" />




</FrameLayout>
<LinearLayout
 android:layout_width="match_parent"
 android:layout_height="50dp"
 android:id="@+id/category_linearlayout">
<TextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:singleLine="true"
android:id="@+id/category_textView"
/>
</LinearLayout>

</LinearLayout>

</FrameLayout>
style.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

</style>
<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>

@颜色/原色
@颜色/原色暗
@颜色/颜色重音
style-v21.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

</style>
<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>

假的
真的
真的
@android:彩色/透明
AppTheme是活动中使用的样式。

编辑1

我在FrameLayout的背景中使用了一种颜色来检查它是否在状态栏下。事实并非如此。

所以我想问题不在于布局

编辑2 这是期望的结果

在style-v21中,您覆盖了样式AppTheme.NoActionBar,但您说您在活动中使用的样式是AppTheme样式


您需要在style-v21中覆盖AppTheme布局,或者在活动中定义AppTheme.NoActionBar。

是的,谢谢:)我现在注意到了。我会的。但是它不会对棒棒糖前的版本产生影响。我相信问题在于缩放。尝试将scaleType=“centerCrop”或“fitXY”添加到您的imageViewNope,这是相同的。请检查编辑。问题不在于操作栏,而在于imageView。设置宽度/高度以匹配父级并应用我所说的缩放类型,它将工作。android:layout\u width=“match\u parent”android:layout\u height=“match\u parent”android:scaleType=“centerCrop”