I am learning Android Studio and I made my first app. When I run it, there is a bar (is it a right name for it?) that I don't want (this with three dots on the right). How to remove it? I was trying with changing AndroidManifest.xml android:theme but app started crashing.
http://i.stack.imgur.com/uKJsI.png
In styles.xml, select a theme with no action bar.
For example
Theme.AppCompat.Light.NoActionBar
Also
1) exend your class from Activity instead of ActionBarActivity
2) remove method onCreateOptionsMenu (if present) from your activty
3) remove method onOptionsItemSelected (if present) from your activity
In the Android Manifest change the theme to the following
android:theme="#android:style/Theme.NoTitleBar"
Sorry but i am confused that whether you want to remove the whole bar (ActionBar) or you want to remove the "three dots (menu)" on the right of the bar...
If you want to remove the whole bar then try this:
Put this under your activity tag in android manifest
`android:theme="#android:style/Theme.NoTitleBar"`
and if you want to remove those three dots then "Saeid Yazdani" is right.
Your activity likely extends ActionBarActivity and the OnCreateOptionsMenu method is created by default.
To note, you should put the Activity back into the Manifest and edit the Actvity Java class file.
Related
I have used Theme.AppCompat.Light.NoActionBar in my styles.xml to remove the action bar in my Android application. In all activities, I'm including a toolbar instead.
I am using a third party library (http://kokum.io) for user login in the app. I do not have control over the activity XML or code for the login screen that the library uses for authentication. The top of this activity is going behind the status bar.
Is it possible to make the activity show up below the status bar without access to the activity code/XML?
I figured out the solution.
In AndroidManifest.xml we can specify themes specifically for each Activity.
<activity
android:name="io.kokum.integration.LoginActivity"
android:theme="#style/CustomTheme" />
This can override the app level theme specifically for this activity.
In the specific case above, I was able to use a theme that provides an action bar to fix the issue.
my problem is simple, it is relative to only Lollipop 5.0
I have a main activity where I set a certain theme then I set programmatically a custom background to the actionbar:
context.getActionBar().setBackgroundDrawable(context.getResources().getDrawable(
getCustomColor(context, Theme)));
Then I open another activity, where I set my custom theme, and my custom background drawable, this time made traslucent:
mActionBarBackgroundDrawable.setAlpha(0);
context.getActionBar().setBackgroundDrawable(
mActionBarBackgroundDrawable);
When I press back, if finishes the activity correctly but then my main activity has the actionbar completely transparent!
It is as if changing the background of the actionbar in my 2nd activity, changes it also to the 1st one!
It works correctly from android 4.0 to 4.4.4
Can you help me?
Thanks and regards
What is your context here? If it is pointing to the Application, it might do so. Try directly using
getActionBar().setBackgroundDrawable(mActionBarBackgroundDrawable);
in your Activity or if you are calling from Fragment
getActivity()getActionBar().setBackgroundDrawable(mActionBarBackgroundDrawable);
I am trying to display the options menu in another place but the ActionBar, is it is hidden.
I have no clue on how to do it nor I find any function to do such things.
I am using Theme.Light.NoTitleBar as theme/style, but still I'd like to have the menu somewhere else, be it a View or a Layout.
Does anyone have any clue?
You would need to use Android support library , which would enable you to use Action Bar in Android Version 11.0 and above. You would also require to use Theme.Holo.Light.DarkActionBar as your application theme to make action bar visible.
After you do this , you may create menu xml file ad inflate it in onCreateOptionsMenu() function , and you can then access Action Bar like this : getActionBar() in your activity.
Now I have my nifty custom title bar in its own XML layout file and I've got my custom theme and style XML files. From my Activity class I can invoke it and it looks great.
Problem is my app has 14 Activities, each with their associated layout file. If I want to see the same title bar appear across my app, i.e., in all my Activities, the two main strategies I've seen are:
Put a an <include layout="#layout/my_title_bar" /> for my title bar in every layout file
...or...
Change all my Activity classes to derive from some common Activity that invokes the new title bar
Before I go off and do one of these I just want to make sure there's no more "centralized' way of doing it, like, say, in the manifest. There's no need to declare the default title bar in every activity, and it doesn't seem right to have to make separate changes for each activity for an app-wide feature like a custom title bar.
Thanks in advance for any tips!
Is it possible to use ActionBar without activity? I want to use it in the StatusBar view, instead of view highlighted with purple color.
This screen shot, based on an image from the Android ui pages, labels the different components, just to make sure we're talking about the same thing.
You can't add an ActionBar outside of an Activity. You need an Activity to get an ActionBar reference. ActionBar references are retrieved via the Activity API, by calling the getActionBar() method inside the Activity.
So you can't use an ActionBar to replace the StatusBar. You can change the StatusBar's color, and possibly layout, but only on a rooted phone. See this forum discussion for some perspective on the issue.
AFAIK, there is no API for changing the Notification Drawer's layout and functionality. There are no API methods that allows us to place an ActionBar inside the drawer outside of the notifications e.g. at the top of the drawer like in your screenshot.
You can create custom layouts for notifications(the messages inside the drawer). The Android Developer pages have an example on how to do it (see "Creating a Custom Notification Layout" at the bottom of the page). Again, you can't use an ActionBar but you can add Views to a Notification layout.
Use notifications. You will see something in the status bar and no Activity will be involved.
There's GOT to be a way to change the ActionBar from a class declared within an Activity:
(1) create method in activity to .setTitle
(2) pass activity context to Controller class (MVC) declared in Activity
(3) have Controller class call activity method to modify actionBar
...what do you think?
You should make a custom rom to change that view.
That Purple View is not part of your application but a part of Android.
If you do not want an Activity, why not make it transparent.
How do I create a transparent Activity on Android?