ActionBar inside a Layout - android

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

Related

What would be a good way to show activity title without actionbar?

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.

Set Title Margin Android ActionBar programatically

Is there anyway to margin ActionBar title programatically? My context is:
I use my main Activity with NoActionBar theme. So i use a toolbar as Actionbar. I have many fragments using as different screen in Main Activity. I want to margin some of fragment title.
Thank in advance.
There are some rules for accuracy of designing ...
they are define as belove with image..
1. your image view
margin of image view from left edge is always 16
2.your textview
margin of your textview from left edge is always 72
Thats why all our android application should work properly...and at least same lookup...
please follow this link for material designing....Link
hope it help a lots...

How can I do to customize the actionbar?

Hi guys I wanna ask you if it is possible to completely redesign the actionbar. I have no buttons on my bar and I want to place a "png" file instead of the default bar..is it possible? Thank you so much :)
It is possible not to use any ActionBar at all.
Just place any control which has a drawable background settable (I normally use a TextView) on the top of your Activity and set its background image.
A TextView may also contain a title and one or more "icons" (compound drawables).
And it's also clickable, if needed.
If you design your layout properly; a RelativeLayout container (I prefer this kind of container) may help: set the TextView as alignParentTop="true" and the map as layout_below="#id/yourTextView_ID" and layout_height="match_parent" (to fill the remaining space).
Let the RelativeLayout be the overall (root) container, so that it contains everything.
As such, its children can be positioned relatively.
To let the map be positioned under the "title", Just skip the layout_below attribute to the map. And add alignParentTop="true" to it.
If you don't use action bar functionality like Up navigation or drawer navigation toogle from action bar.You can use at window like this and style your title in your theme:
getWindow.requestFeature(FEATURE_CUSTOM_TITLE);
And at style file like this:
<item name="android:windowTitleSize">#dimen/title_height</item>
<item name="android:windowTitleBackgroundStyle">#style/WindowTitleBackground</item>
<item name="android:windowTitleStyle">#style/CustomWindowTitle</item>
If you want to use action bar functionality, override action bar custom view by this:
getActionBar().setCustomView(R.layout.custom_actionbar);

Align sherlock actionbar below listview

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.

How to set drawables on actionbar of my android application

I'm developing an application in which I have to put drawables on top of the actionbar and have to update then from time to time. Here is a layout what I want it to look like.
I want to put a drawable as shown in the picture atttached(The green color drawable not the notification thing). Is that possible to achieve this kind of screen in android? If, so please guide me how to achieve this.
Any kind of help will be appreciated.
This is easy using a custom view. Let me explain you the steps briefly:
Create your custom view in the layout folder. For example, an ImageButton.
Set this view as the custom view of the action bar in your activity. You can do this by calling
getSupportActionBar().setCustomView(R.layout.your_custom_view);
(or getActionBar() instead of getSupportActionBar())
Call setDisplayOptions() with the ActionBar.DISPLAY_SHOW_HOME and ActionBar.DISPLAY_SHOW_CUSTOM options.
If you have other standard buttons in the action bar, inflate the menu.
You can finally set the OnClickListener for your custom view.
This worked for me, hope it helps you!
Create custom view
Use it as ActionView in ActionBar
In onCreateOptionsMenu get a reference to your view and update it when needed

Categories

Resources