Created
December 26, 2016 01:38
-
-
Save budioktaviyan/f24fde2024f4b38686223fa780baa27d to your computer and use it in GitHub Desktop.
Main Activity Class
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
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(@Nullable final Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_main); | |
toolbar.setTitle(getResources().getString(R.string.app_name)); | |
toolbar.setPadding(0, getStatusBarHeight(), 0, 0); | |
setSupportActionBar(toolbar); | |
} | |
private int getStatusBarHeight() { | |
final int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); | |
return resourceId > 0 ? getResources().getDimensionPixelSize(resourceId) : 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment