I have an activity which is extended from SherlockActivity.
Situation:
The actionbar is not aligned above the listview, which uses the whole screen of the activity.
They are on top of each other!
I would like not to using paddingTop inside lisview... there have to be another cool way :).
Are you sure you are using the correct theme? You should be using one of the Theme.Sherlock... ones.
Related
Im making an app for android, without actionbar.
What is best practice for showing titles without actionbar?
The best practice is basically never using an action bar. This gives you a complete device screen to play with.
You can use images or different text styles for showing the title. You can also use interesting icons.
To remove action bar -
Go to res > values > styles.xml
Here is an illustration of styles file -
You can use the Toolbar (it's like the action bar, but more flexible). For example, action bar needs to be on top of the screen, but toolbar can have place anywhere in the layout.
You title can be shown as text or a beautiful asset.
If, for some reason, you don't want to use the toolbar, you can think about something like having a scrollView with the title on top of it.
Use a regular LinearLayout with a TextView inside. Style according to your needs, and set the text in the xml, or programmaticaly using TextView's setText() method.
My question is how do I do make the ActionBar transparent (and also the status bar)?
I'm having trouble trying to make use of the AppBarLayout and Toolbars on Android to achieve that.
I need that because I want to create an application that has one main Activity that holds a DrawerLayout and many screens which are mostly fragments. Then, there is some screens where the ActionBar and StatusBar becomes transparent (while still having the hamburger button for the DrawerLayout).
I've tried changing the AppBarLayout and the Toolbar, but it looks weird... It looks like there are some weird margins on the ActionBar.
appBarLayout.setBackgroundColor(ContextCompat.getColor(this, android.R.color.transparent));
toolbar.setBackgroundColor(ContextCompat.getColor(this, android.R.color.transparent));
And here is the result:
And here is it before changing the color/changing it back:
Any ideas on how to achieve the transparency on the ActionBar when some fragments are attached to the main content of the main Activity?
If you want to take a look at the code, here is the repository: Sample Repo.
Okay...
I made a mistake here...
First, all you need to do is remove the paddings on the content_main.xml and set the elevation of the appBarLayout to 0 and the code will work. (You'd need to set it back to its original value if you need the shadows).
I updated the repo to fix that and it should be working now.
But, There is another way to solve this problem using a fragment with its own AppBarLayout/Toolbar and hiding and showing the MainActivity AppBarLayout when you're showing the Fragment inner one.
I'll create a branch in the same repository to show what I mean.
Please, answer/comment with better solutions/ideas if have them.
Repo here.
Its possible that a layout contain a actionbar?
Or change the width of the actionbar?
For this part of my application i dont need a fragmentactivity, so this is a simple activity
Sorry by my English..
Green: Layouts
Red:Actionbar
If You want that your actionbar appears in some part of screen you should use Customlayout with the use of "Include Other Layout Option" in your screen..
or If you want to customize your actionbar, You Can Use Custom Actionbar.
http://javatechig.com/android/actionbar-with-custom-view-example-in-android
i'm building an app and i really want to align buttons to the left using ABS (action bar sherlock) 4.0
I really like the dropbox interface as shown under this:
So, my question is: How can i align the buttons to the left and how can i jump between views in ViewFlow using buttons?
I've seen that people can add tabs to their ABS, but not with the title like the Dropbox interface.
Thanks.
Also if u need my sourcecode i will add it later if needed.
Regards
Stian Instebø
setCustomView() is the magic method you might be looking for.
To achieve the same layout shown in the Dropbox app, you would first call setDisplayShowHomeEnabled(false) on your ActionBar.
Next, you could define the layout for the buttons somewhere in XML. Once this is done, calling setCustomView(R.layout.my_actionbar_nav) will do the trick. (It will now be positioned on the left-hand side of the ActionBar).
It'll be your responsibility to wire up the appropriate onClick listeners for your layout's inner button Views, but it's not a bad price to pay for setting up custom navigation.
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?