ActionBar Code Java

Action bar code :


1. Action bar full screen

Note : Add code in add source directly (MainActivity)

//full screen  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

//unfullscreen getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

Screenshoot :

2. ActionBar-Change home button

Note : 
- Add code in add source direcly
- if in your project have appcompat Change Actionbar on SupportActionbar.
- Replace ic_home with your imageview name.

getActionBar().setHomeAsUpIndicator(R.drawable.ic_home);

Screenshoot  :

3. ActionBar- Change Title Name

Note:
- Add code in add source directly
- change ("Title") with your title name.
- if in your project have appcompat Change Actionbar to SupportActionbar

getActionBar().setTitle("Title");

Screenshoot :

4. Actionbar- Subtitle

Note : 
- Add code in add source directly
- if in your project have appcompat Change Actionbar to SupportActionbar

getActionBar().setSubtitle("Subtitle");


5. Actionbar- Show/Hide

Note :
- Add code in add source direcly
- if in your project have appcompat Change Actionbar to SupportActionbar

//show actionbar 

 getActionBar().show();

//hide ActionBar

 getActionBar().hide();

//APPCOMPAT (show) 

 getSupportActionBar().show();

//APPCOMPAT (hide) 

 getSupportActionBar().hide();


6. Actionbar- Change Color

Note :
- Add code in add source direcly
- if in your project have app compat Change Actionbar to SupportActionbar



//ActionBar Color

ActionBar actionBar = getActionBar(); actionBar.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(Color.parseColor("#191919"))); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window w = MainActivity.this.getWindow(); w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); w.setStatusBarColor(Color.parseColor("#000000")); }

Posting Komentar

0 Komentar

AG VPN PRO