Any one can share the mainfest.xml.
How to set it? then can remove the label..?
Thanks very much
Your question isn't very clear, but assuming you're asking about displaying the name of your application: There's a line in the < application > section that has "#string/app_name" in it, which you could remove. Not sure that's a good idea though. Alternatively you might be asking how to remove the title bar at the top of an application. If so, use
requestWindowFeature(Window.FEATURE_NO_TITLE);
If by removing the default label, you mean removing the title bar, you can use the following in your onCreate
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
}
Related
I tried to create a new Android application and I tried to hide the action bar in the constructor of MainActivity, using the line requestWindowFeature(Window.FEATURE_NO_TITLE);
I've done this previously many times and there wasn't any problem in this. But when I try the same now it throws a error mentioning that "request feature must be called before adding the content"
Even I've tried adding this line in various positions but there wasn't any change in result. Can anyone help me solving this issue.
There are two ways to hide actionbar. I am assuming you are using Theme.AppCompat.Light style and your activity extends ActionBarActivity.
Set below lines to your styles.xml
<item name="windowActionBar">false</item>
Or
Set below lines in your java file.
getSupportActionBar().hide();
You can try like this:
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
super.onCreate(savedInstanceState);
It should be called before setContentView() method in onCreate() method of Activity.
You should add requestWindowFeature(Window.FEATURE_NO_TITLE); before super.onCreate(savedInstanceState);
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
This should work.Put this after super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
All the best.
I have tried several things in order to hide the status bar in my app. It seems to work, but several users complain they still see the status bar. So, it looks like all proper solutions I have used, do not cover all devices/settings.
Here are the things I already added to my project:
In the AndroidManifest:
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen"
In the onCreate() method:
requestWindowFeature( Window.FEATURE_NO_TITLE );
getWindow().setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN );
getWindow().getDecorView().requestLayout();
Now, this does work for almost all of my users. But some of them still see the status bar, even Galaxy S2 and S3 users (NOT ALL!).
Are there any other options left that I could try?
Try using only the Java code in onCreate() without the android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen".
Put the Java code to the beginning of your onCreate():
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Here is a pic of android applicationbar i like ( I mean the part where settings is written on, not sure if applicationbar is the right name :) )
http://oi50.tinypic.com/ehwwpc.jpg
Some apps i have downloaded also have the exact same bar so im guessing its a predefined theme but when i make a project (theme.holo) then my applicationbar is just totally black.
So my question is how do i get the same project bar?
Thank you!
Edit:
I found that all apps are opensoruce and i looked out settings apps manifest for android 4.0.4, same as mine.
Here it is: https://android.googlesource.com/platform/packages/apps/Settings/+/android-4.0.4_r2.1/AndroidManifest.xml
Whats strange is that it uses the same theme i do: android:theme="#android:style/Theme.Holo"
... but still the titlebar is different. There must be another attribute somewhere that defines the titlebar? Does anyone have an idea? :)
The title of the activity can be defined in the Manifest file, and it should be android:label property. For example:
<activity
android:name=".MainActivity"
android:label="#string/TitleBarText" />
TitleBarText is the android string resource that contains the name of the title.
If you wish to do it from code, you can just do the following in the onCreate method:
#Override
public void onCreate(Bundle savedInstanceState) {
setTitle("Title Bar Name");
setContentView(R.layout.activity_main);
}
To create a custom title bar, refer to: this and this
I found bunch of samples how to remove title/notification bar on Android. However, it's still not a full screen.
I still see a panel on my table with search, home, back and some other button.
Do you have any ideas how to hide this panel?
Generally speaking, I want kind of kiosk mode.
Use this code in onCreate of activity:
getWindow().setFlags(LayoutParams.FLAG_FULLSCREEN, LayoutParams.FLAG_FULLSCREEN);
Sample code for a fullscreen activity:
public class HellofullActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}
where you request that the window has not the green title bar and take full screen.
The core problem was device specific. I was doing development for Archos and Archos has it's own bar, which isn't not removed by FLAG_FULLSCREEN and FEATURE_NO_TITLE
In my android app I set
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN );
Then my touch screen event doesnt’ work any more.
Further Explaining,
I have a button and onClick it changes the contentView by setContentView(R.layout.choose_player);.
It works fine. But if you take the focus to the button by the trackball(making it yellow) and tap on it, it gives the exception.
java.lang.IllegalArgumentException: parameter must be a descendant of this view
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main1);
}
public void onClick(View v) {
setContentView(R.layout.main2);
}
i cant understand properly first. I think you may be using setContentView method multiple times. one is to set the layout on the view. another one inside the click event. right? that not works. use that method once to set the layout. on click event you have to do your tasks on the views inside the layout. hope it helps. please post some code snippets for the perfect answers.
you use setContentView only once in your 'onCreate' method, in general for the main window (one Activity = 1 view)
in your case you should probably change your Background..