Я пытаюсь установить прозрачную строку состояния (как на превью), но похоже на видео: https://yadi.sk/i/HcYJa3VB3WYGvL
Предварительный просмотр:
Я пробовал установить в стилях xml
<item name = "android:windowBackground">@android:color/transparent< /item>
в разных макетах, также установите
fitsSystemWindows = "true"
MainActivity.xml:
<android.support.v4.widget.DrawerLayout
...
android:fitsSystemWindows = "true">
<android.support.design.widget.CoordinatorLayout
android:id = "@+id/coordinator_container"
android:fitsSystemWindows = "true"
android:layout_height = "match_parent"
android:layout_width = "match_parent">
<android.support.design.widget.AppBarLayout
android:id = "@+id/app_bar"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:theme = "@style/AppTheme.AppBarOverlay"
android:background = "@color/color_primary">
<android.support.design.widget.CollapsingToolbarLayout
...
app:contentScrim = "@color/color_primary"
android:fitsSystemWindows = "true"
app:layout_scrollFlags = "scroll|exitUntilCollapsed">
<ImageView
android:id = "@+id/user_photo"
android:layout_width = "match_parent"
android:layout_height = "@dimen/profile_image_size"
android:scaleType = "centerCrop"
android:src = "@drawable/user_photo"
app:layout_collapseMode = "parallax"
android:fitsSystemWindows = "true"/>
<android.support.v7.widget.Toolbar
android:id = "@+id/toolbar"
android:layout_width = "match_parent"
android:layout_height = "?attr/actionBarSize"
android:theme = "@style/AppTheme.PopupOverlay"
app:titleTextColor = "@color/white"
app:layout_collapseMode = "pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_height = "match_parent"
android:layout_width = "wrap_content"
app:layout_behavior = "@string/appbar_scrolling_view_behavior">
...
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
.../>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
...>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
v21 / style.xml:
<?xml version = "1.0" encoding = "utf-8"?>
<resources>
<style name = "AppTheme" parent = "Theme.AppCompat.Light.NoActionBar">
<item name = "colorPrimary">@color/color_primary</item>
<item name = "colorPrimaryDark">@color/color_primary_dark</item>
<item name = "colorAccent">@color/color_accent</item>
<item name = "android:windowDrawsSystemBarBackgrounds">true</item>
<item name = "android:statusBarColor">@color/color_accent</item>
<item name = "android:windowTranslucentStatus">true</item>
</style>
</resources>
Все, что вам нужно сделать, это установить эти свойства в своей теме:
<item name = "android:windowTranslucentStatus">true</item>
<item name = "android:windowTranslucentNavigation">true</item>
Для вашего макета действия / контейнера, для которого вы хотите иметь прозрачную строку состояния, необходимо установить это свойство:
android:fitsSystemWindows = "true"
Уже есть ответ на этот вопрос. Подписаться: Android Полностью прозрачная строка состояния?
Есть два разных случая:
1.Если вы хотите слегка прозрачную строку состояния (как вы описали в своем вопросе)
<style name = "ThemeActionBar" parent = "Widget.AppCompat.Light.ActionBar.Solid">
<item name = "android:background"> @null </item>
<!-- Support library compatibility -->
<item name = "background">@null</item>
<item name = "android:displayOptions"> showHome | useLogo</item>
<item name = "displayOptions">showHome|useLogo</item>
2.Для полностью прозрачной строки состояния:
<item name = "android:windowTranslucentStatus">true</item>
<item name = "android:windowTranslucentNavigation">true</item>
проверьте этот отвечать, вы понимаете, как все работает.
добавьте это в свою тему
<item name = "android:windowTranslucentStatus">true</item>
<item name = "android:windowTranslucentNavigation">true</item>
Установите android: fitsSystemWindows = "true" в корневой контейнер.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
добавить в свою деятельность
Возможный дубликат Android Полностью прозрачная строка состояния?