Implement transparent status bar for android.support.v7.widget.Toolbar

Implement transparent status bar for android.support.v7.widget.Toolbar - Hello Friend GENERAL INFO FOR ANDROID DEVELOPMENT, In the article you read this time with the title Implement transparent status bar for android.support.v7.widget.Toolbar, We have prepared this article for you to read and retrieve information there in. Hopefully the contents of postings Artikel android.support.v7.widget.Toolbar, We write this you can understand. Alright, good read.

The Title : Implement transparent status bar for android.support.v7.widget.Toolbar
link : Implement transparent status bar for android.support.v7.widget.Toolbar

Read also


Implement transparent status bar for android.support.v7.widget.Toolbar

Implement transparent status bar for android.support.v7.widget.Toolbar:

- Follow the steps in "Replace ActionBar with android.support.v7.widget.Toolbar" to implement a simplest toolbar.


- Edit styles.xml to add the item of "android:windowTranslucentStatus".
<resources>

<!-- Base application theme. -->
<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>
<item name="android:windowTranslucentStatus">true</item>
</style>

</resources>


Edit MainActivity.java to set the padding (with the height of status bar) of the status.
package com.blogspot.android_er.androidtoolbarex2;

import android.content.res.Resources;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

toolbar.setPadding(0, getStatusBarHeight(), 0, 0);

}

private int getStatusBarHeight() {
int height;

Resources myResources = getResources();
int idStatusBarHeight = myResources.getIdentifier(
"status_bar_height", "dimen", "android");
if (idStatusBarHeight > 0) {
height = getResources().getDimensionPixelSize(idStatusBarHeight);
Toast.makeText(this,
"Status Bar Height = " + height,
Toast.LENGTH_LONG).show();
}else{
height = 0;
Toast.makeText(this,
"Resources NOT found",
Toast.LENGTH_LONG).show();
}

return height;
}

}


After finished:






Thus Article Implement transparent status bar for android.support.v7.widget.Toolbar

The End Article Implement transparent status bar for android.support.v7.widget.Toolbar This time, hopefully can give benefits to all of you. well, see you in posting other articles.

You are now reading the article Implement transparent status bar for android.support.v7.widget.Toolbar with the link address http://xorislogo.blogspot.com/2017/02/implement-transparent-status-bar-for.html

0 Response to "Implement transparent status bar for android.support.v7.widget.Toolbar"

Post a Comment