how to set status bar with gradient drawable same as action bar?












3















i have tried many ways but it overlaps toolbar and status bar.Also it gives back press bottom navigation default.
i have added below code-



 @Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow(); w.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);//allow window to extend outside of the screen.
w.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);// override FLAG_FULLSCREEN and force the screen decorations (such as the status bar) to be shown. w.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_ATTACHED_IN_DECOR); w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); w.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}
super.onCreate(savedInstanceState);

}


enter image description here










share|improve this question

























  • are you using NoActionBarTheme and creating your own toolbar? or the other way around? The UI looks pretty good btw.

    – devDeejay
    Nov 24 '18 at 6:37













  • thanks for response,yes i am using custom toolbar and i have aaded drawble gradient file to toolbar background

    – Prachi rane
    Nov 24 '18 at 6:47











  • @Prachi rane i have posted a code have look at this stackoverflow.com/a/48556397/7609347

    – Vivek Barai
    Nov 24 '18 at 7:12


















3















i have tried many ways but it overlaps toolbar and status bar.Also it gives back press bottom navigation default.
i have added below code-



 @Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow(); w.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);//allow window to extend outside of the screen.
w.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);// override FLAG_FULLSCREEN and force the screen decorations (such as the status bar) to be shown. w.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_ATTACHED_IN_DECOR); w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); w.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}
super.onCreate(savedInstanceState);

}


enter image description here










share|improve this question

























  • are you using NoActionBarTheme and creating your own toolbar? or the other way around? The UI looks pretty good btw.

    – devDeejay
    Nov 24 '18 at 6:37













  • thanks for response,yes i am using custom toolbar and i have aaded drawble gradient file to toolbar background

    – Prachi rane
    Nov 24 '18 at 6:47











  • @Prachi rane i have posted a code have look at this stackoverflow.com/a/48556397/7609347

    – Vivek Barai
    Nov 24 '18 at 7:12
















3












3








3








i have tried many ways but it overlaps toolbar and status bar.Also it gives back press bottom navigation default.
i have added below code-



 @Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow(); w.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);//allow window to extend outside of the screen.
w.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);// override FLAG_FULLSCREEN and force the screen decorations (such as the status bar) to be shown. w.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_ATTACHED_IN_DECOR); w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); w.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}
super.onCreate(savedInstanceState);

}


enter image description here










share|improve this question
















i have tried many ways but it overlaps toolbar and status bar.Also it gives back press bottom navigation default.
i have added below code-



 @Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow(); w.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);//allow window to extend outside of the screen.
w.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);// override FLAG_FULLSCREEN and force the screen decorations (such as the status bar) to be shown. w.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_ATTACHED_IN_DECOR); w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); w.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}
super.onCreate(savedInstanceState);

}


enter image description here







android gradient drawable statusbar






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 '18 at 13:08









Vivek Barai

648718




648718










asked Nov 24 '18 at 6:32









Prachi ranePrachi rane

143




143













  • are you using NoActionBarTheme and creating your own toolbar? or the other way around? The UI looks pretty good btw.

    – devDeejay
    Nov 24 '18 at 6:37













  • thanks for response,yes i am using custom toolbar and i have aaded drawble gradient file to toolbar background

    – Prachi rane
    Nov 24 '18 at 6:47











  • @Prachi rane i have posted a code have look at this stackoverflow.com/a/48556397/7609347

    – Vivek Barai
    Nov 24 '18 at 7:12





















  • are you using NoActionBarTheme and creating your own toolbar? or the other way around? The UI looks pretty good btw.

    – devDeejay
    Nov 24 '18 at 6:37













  • thanks for response,yes i am using custom toolbar and i have aaded drawble gradient file to toolbar background

    – Prachi rane
    Nov 24 '18 at 6:47











  • @Prachi rane i have posted a code have look at this stackoverflow.com/a/48556397/7609347

    – Vivek Barai
    Nov 24 '18 at 7:12



















are you using NoActionBarTheme and creating your own toolbar? or the other way around? The UI looks pretty good btw.

– devDeejay
Nov 24 '18 at 6:37







are you using NoActionBarTheme and creating your own toolbar? or the other way around? The UI looks pretty good btw.

– devDeejay
Nov 24 '18 at 6:37















thanks for response,yes i am using custom toolbar and i have aaded drawble gradient file to toolbar background

– Prachi rane
Nov 24 '18 at 6:47





thanks for response,yes i am using custom toolbar and i have aaded drawble gradient file to toolbar background

– Prachi rane
Nov 24 '18 at 6:47













@Prachi rane i have posted a code have look at this stackoverflow.com/a/48556397/7609347

– Vivek Barai
Nov 24 '18 at 7:12







@Prachi rane i have posted a code have look at this stackoverflow.com/a/48556397/7609347

– Vivek Barai
Nov 24 '18 at 7:12














1 Answer
1






active

oldest

votes


















1














Call this method before setContentView.



@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void setStatusBarGradiant(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = activity.getWindow();
Drawable background = activity.getResources().getDrawable(R.drawable.gradient_theme);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(activity.getResources().getColor(android.R.color.transparent));
window.setNavigationBarColor(activity.getResources().getColor(android.R.color.transparent));
window.setBackgroundDrawable(background);
}
}


Also make sure that you are using the theme AppTheme.NoActionBar. Check this. If it doesn't work check the other answers to the question.



To hide the bottom navigation bar use this



View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);


Check this for more info.






share|improve this answer


























  • Thanks for answer it works but not removing bottom bar

    – Prachi rane
    Nov 24 '18 at 7:09











  • Which bottom bar are you talking about?

    – Dev Sharma
    Nov 24 '18 at 7:11











  • which is in grey color

    – Prachi rane
    Nov 24 '18 at 10:26











  • I edited my answer. Check it out.

    – Dev Sharma
    Nov 24 '18 at 12:06











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53455770%2fhow-to-set-status-bar-with-gradient-drawable-same-as-action-bar%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Call this method before setContentView.



@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void setStatusBarGradiant(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = activity.getWindow();
Drawable background = activity.getResources().getDrawable(R.drawable.gradient_theme);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(activity.getResources().getColor(android.R.color.transparent));
window.setNavigationBarColor(activity.getResources().getColor(android.R.color.transparent));
window.setBackgroundDrawable(background);
}
}


Also make sure that you are using the theme AppTheme.NoActionBar. Check this. If it doesn't work check the other answers to the question.



To hide the bottom navigation bar use this



View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);


Check this for more info.






share|improve this answer


























  • Thanks for answer it works but not removing bottom bar

    – Prachi rane
    Nov 24 '18 at 7:09











  • Which bottom bar are you talking about?

    – Dev Sharma
    Nov 24 '18 at 7:11











  • which is in grey color

    – Prachi rane
    Nov 24 '18 at 10:26











  • I edited my answer. Check it out.

    – Dev Sharma
    Nov 24 '18 at 12:06
















1














Call this method before setContentView.



@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void setStatusBarGradiant(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = activity.getWindow();
Drawable background = activity.getResources().getDrawable(R.drawable.gradient_theme);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(activity.getResources().getColor(android.R.color.transparent));
window.setNavigationBarColor(activity.getResources().getColor(android.R.color.transparent));
window.setBackgroundDrawable(background);
}
}


Also make sure that you are using the theme AppTheme.NoActionBar. Check this. If it doesn't work check the other answers to the question.



To hide the bottom navigation bar use this



View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);


Check this for more info.






share|improve this answer


























  • Thanks for answer it works but not removing bottom bar

    – Prachi rane
    Nov 24 '18 at 7:09











  • Which bottom bar are you talking about?

    – Dev Sharma
    Nov 24 '18 at 7:11











  • which is in grey color

    – Prachi rane
    Nov 24 '18 at 10:26











  • I edited my answer. Check it out.

    – Dev Sharma
    Nov 24 '18 at 12:06














1












1








1







Call this method before setContentView.



@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void setStatusBarGradiant(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = activity.getWindow();
Drawable background = activity.getResources().getDrawable(R.drawable.gradient_theme);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(activity.getResources().getColor(android.R.color.transparent));
window.setNavigationBarColor(activity.getResources().getColor(android.R.color.transparent));
window.setBackgroundDrawable(background);
}
}


Also make sure that you are using the theme AppTheme.NoActionBar. Check this. If it doesn't work check the other answers to the question.



To hide the bottom navigation bar use this



View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);


Check this for more info.






share|improve this answer















Call this method before setContentView.



@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void setStatusBarGradiant(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = activity.getWindow();
Drawable background = activity.getResources().getDrawable(R.drawable.gradient_theme);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(activity.getResources().getColor(android.R.color.transparent));
window.setNavigationBarColor(activity.getResources().getColor(android.R.color.transparent));
window.setBackgroundDrawable(background);
}
}


Also make sure that you are using the theme AppTheme.NoActionBar. Check this. If it doesn't work check the other answers to the question.



To hide the bottom navigation bar use this



View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);


Check this for more info.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 24 '18 at 12:05

























answered Nov 24 '18 at 6:44









Dev SharmaDev Sharma

3810




3810













  • Thanks for answer it works but not removing bottom bar

    – Prachi rane
    Nov 24 '18 at 7:09











  • Which bottom bar are you talking about?

    – Dev Sharma
    Nov 24 '18 at 7:11











  • which is in grey color

    – Prachi rane
    Nov 24 '18 at 10:26











  • I edited my answer. Check it out.

    – Dev Sharma
    Nov 24 '18 at 12:06



















  • Thanks for answer it works but not removing bottom bar

    – Prachi rane
    Nov 24 '18 at 7:09











  • Which bottom bar are you talking about?

    – Dev Sharma
    Nov 24 '18 at 7:11











  • which is in grey color

    – Prachi rane
    Nov 24 '18 at 10:26











  • I edited my answer. Check it out.

    – Dev Sharma
    Nov 24 '18 at 12:06

















Thanks for answer it works but not removing bottom bar

– Prachi rane
Nov 24 '18 at 7:09





Thanks for answer it works but not removing bottom bar

– Prachi rane
Nov 24 '18 at 7:09













Which bottom bar are you talking about?

– Dev Sharma
Nov 24 '18 at 7:11





Which bottom bar are you talking about?

– Dev Sharma
Nov 24 '18 at 7:11













which is in grey color

– Prachi rane
Nov 24 '18 at 10:26





which is in grey color

– Prachi rane
Nov 24 '18 at 10:26













I edited my answer. Check it out.

– Dev Sharma
Nov 24 '18 at 12:06





I edited my answer. Check it out.

– Dev Sharma
Nov 24 '18 at 12:06




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53455770%2fhow-to-set-status-bar-with-gradient-drawable-same-as-action-bar%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

Refactoring coordinates for Minecraft Pi buildings written in Python