I have an app that switches between full screen and normal screen for a certain condition.
I have successfully done this with the notification but the TITLE BAR still remains hidden after I set it back from full screen to normal screen mode. So HOW DO I SHOW THE TITLE BAR AFTER HIDING IT?
EDIT:
I have come across answers where they make a custom title bar and switch between its visibility but thats not what I want.
CODE:
if(ScreenReceiver.wasScreenOn) {
Toast toast=Toast.makeText(this, "screen was on", Toast.LENGTH_LONG);
toast.show();
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
setContentView(R.layout.resume);
} else {
Toast toast=Toast.makeText(this, "screen was off", Toast.LENGTH_LONG);
toast.show();
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
setContentView(R.layout.main);
}
try this
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
/// custom tittle bar declaration
final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
/// custom tittle bar creation ///....
if (customTitleSupported) {
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.tittle_bar);
}
final TextView myTitleText = (TextView) findViewById(R.id.title_bar);
if (myTitleText != null) {
myTitleText.setText("Categories");
}
Related
App crashing when using requestWindowFeature(Window.FEATURE_NO_TITLE);
When using the button to make it full screen which when tries to hide the Title bar the app crashes
static int vari = 0;
public void fsc(){
ib = (ImageButton) findViewById(R.id.fulls);
ib.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "Full-Screen", Toast.LENGTH_LONG).show();
if(vari == 0)
{
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
vari = 1;
}
});
I wanted to make it full screen (hiding both status and title bar) on the button press
Please note: this is also to be called to fragments
Check if you have the fullscreen theme set in the manifest?
//if not add this in your manifest
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
// Hide status bar
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
// Show status bar
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
I have an application where the requirement is to show the application version name on the right corner of the application title bar.
Is this possible?
Note that the version name is different color and different size also.
sorry cannot post an image because of not enough reputation.... :(
It is something like
--------------------------------------------------
Application title comes here... v1.23
--------------------------------------------------
It seems like impossible to do that.
The only workaround appears to be using a custom title bar as mentioned in this post android place a textview over application title
Code below for quick help:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
if ( customTitleSupported ) {
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.mytitle);
}
final TextView myTitleText = (TextView) findViewById(R.id.myTitle);
if ( myTitleText != null ) {
myTitleText.setText("MY TITLE");
}
}
hope it helps somebody!
I already have the
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.activity_profile);
and the
setProgressBarIndeterminateVisibility(true);
if (isOnline()) {
retrieveProfile();
} else {
Toast.makeText(ProfileActivity.this, getString(R.string.internet_error), Toast.LENGTH_LONG).show();
}
setProgressBarIndeterminateVisibility(false);
This code was already working, but somehow the progress bar doesn't show anymore.
Any idea would be appreciated!
That function doesn't show the bar, it just makes it show an indeterminate bar rather than a determinate bar. You still need to call setProgressBarVisibility(true);
Try this...
setSupportProgressBarIndeterminateVisibility(boolean)
to get backward compatibility.
I am working on an android project. And I want to show / hide the custom title bar on Button click. This button is for media player (full screen size / custom screen size ) please help me.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_main1);
ctx=this;
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.custom_title1);
// FrameLayout frameLayout = (FrameLayout) findViewById(R.id.menu);
// FrameLayout frameLayout2 = (FrameLayout) findViewById(R.id.menu1);
for hide custom title i am using using following code onClick()
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
This is will hide the action bar:
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this will make him back:
this.requestWindowFeature(Window.FEATURE_ACTION_BAR);
i am setting custom title in my tab activity like this
boolean customTitleSupported;
customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
// customTitleSupported = false;
//check for custom title supported feature
if(customTitleSupported == true) {
customTitleBar();
} else {
requestWindowFeature(Window.FEATURE_LEFT_ICON);
String title = prefManager.getTitle();
setTitle(NAME + " " + title);
}
//Set contentview of activity
setContentView(R.layout.tabactivity);
if(customTitleSupported == false){
setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.logo);
}
Everything is working fine.But when i make customTitleSupported to FALSE to check if custom title support is not there in sdk then it should call normal setTitle() function.
But if i do this customTitleSupported = false;
i am getting following error
android.util.AndroidRuntimeException: You cannot combine custom titles with other title
features
i am not clearly understanding the problem if custom title is not supported why i cannot request for other title features.If i doest not request for custom title then else part of setting icon and title works but i want to handle both conditions together.
Thanks
You canot use other title features with FEATURE_CUSTOM_TITLE, and you cannot turn off a feature once requested: check doc
You just have to use setFeatureInt(int featureId, int value) and provide a layout resource ID at "value". Check this example: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/CustomTitle.html