Last active
June 27, 2019 07:59
-
-
Save claireliu14/0062f4beaef16bcd7b29c4ddefd70b1b to your computer and use it in GitHub Desktop.
Make App bar and Status bar transparent.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- activity_main.xml (root) --> | |
+ android:fitsSystemWindows="true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- app_bar_main.xml --> | |
<com.google.android.material.appbar.AppBarLayout | |
android:paddingTop="24dp" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:background="@android:color/transparent" | |
android:theme="@style/AppTheme.AppBarOverlay" | |
app:elevation="0dp"> | |
<androidx.appcompat.widget.Toolbar | |
android:id="@+id/toolbar" | |
android:layout_width="match_parent" | |
android:layout_height="?attr/actionBarSize" | |
app:popupTheme="@style/AppTheme.PopupOverlay" /> | |
</com.google.android.material.appbar.AppBarLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
// setting status bar | |
Window window = this.getWindow(); | |
window.setFlags( | |
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, | |
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); | |
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); | |
setContentView(R.layout.activity_main); | |
// ... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- styles.xml --> | |
<resources> | |
<!-- Base application theme. --> | |
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | |
<!-- Customize your theme here. --> | |
... | |
<item name="android:windowTranslucentStatus">true</item> | |
</style> | |
<style name="AppTheme.NoActionBar"> | |
<item name="windowActionBar">false</item> | |
<item name="windowNoTitle">true</item> | |
<item name="android:windowTranslucentStatus">true</item> | |
</style> | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- v21\styles.xml --> | |
<resources> | |
<style name="AppTheme.NoActionBar"> | |
... | |
<item name="android:windowDrawsSystemBarBackgrounds">false</item> | |
<item name="android:windowTranslucentStatus">true</item> | |
</style> | |
</resources> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment