Using the Spinner as view-switching controller at Action Bar - android

I would like to use the Spinner as view-switching controller at Action Bar in my Android app, just like the native mail app (see part #2 at Android Common App UI).
So far I have managed putting the Spinner in the action bar and populating it with array of strings (see screen shot here) by looking at the example code at Android Developers.
My questions are:
How can I hide the activity name "MyAcitivity" from the action bar so the Spinner gets more place?
How can I make Spinner displaying two lines, one for the title and other for subtitle? Just like in the native mail app.
Why is the item text in the Spinner black and not white as the rest of the text in action bar?
I'm developing for Android version 4.0 and later.

How can I hide the activity name "MyAcitivity" from the action bar so the Spinner gets more place?
Call setDisplayShowTitleEnabled(false) on the ActionBar for this activity.
How can I make Spinner displaying two lines, one for the title and other for subtitle? Just like in the native mail app.
Create layouts that have more than one line in them that you use with your SpinnerAdapter.
Why is the item text in the Spinner black and not white as the rest of the text in action bar?
Probably you need to use getThemedContext() on ActionBar to get the Context to use with your SpinnerAdapter constructor.

1.How can I hide the activity name "MyAcitivity" from the action bar so the Spinner gets more place?
in order to remove this title you should edit the activity tag in manifast to android:label=" "
do this in every activity you wish for
3.Why is the item text in the Spinner black and not white as the rest of the text in action bar?
you can create style for the text color like theme.holo.light and apply this theme to your activity

1) How can I hide the activity name "MyAcitivity" from the action bar so the Spinner gets more place?
If you are using a standard theme, you can just look for the "noTitleBar" version and add it
android:theme="#android:style/Theme.Light.NoTitleBar"
FYI: check this link, it contains more detailed info
2) How can I make Spinner displaying two lines, one for the title and other for subtitle? Just like in the native mail app
I really dont get what you wanna do. If u need a text above and one below a spinning icon, you can just create a linear layout (a vertical one) adding inside of it the 3 elements
3) Why is the item text in the Spinner black and not white as the rest of the text in action bar?
You can modify every element in your layout by editing the style you are using.
FYI: basic theme 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.

Make Android Custom App Bar as Default in every Activity

I want to make android custom app bar that contains searchbox, icon, etc.
The solution on google that I found was changing the style to no action bar. And create a toolbar layout that need to be included in every activity I made.
I just wondering, can I make custom App bar that default appear in every activity without including them when creating Activity?
I would recommend using v7.widget.toolbar. At first you need to create custom layout for your toolbar. Then you need to set it as a support action bar in each activity that you want it to appear. Toolbar on every activity can contains different icons.
https://developer.android.com/training/appbar/setting-up.html

Action bar list navigation + tab navigation - Position of spinner is not at left most

According to Jake as in Android layout with action bar and tabs, we decide to follow his 2nd suggestion.
Use tab navigation in the action bar and set a custom view with a Spinner
Together with IcsSpinner from ActionBarSherlock itself, we manage to make it work in Gingerbread and ICS both.
However, we still suffer the following problem, during landscape mode.
Note, the spinner ("Portfolio 1") is in between PORTFOLIO tab and search icon. What we want is, the spinner is at the left side of WATCHLIST tab.
Is there anything we may try out?
Thanks.
You can set custom view for your action bar, user RelativeLayout to put your spinner at left side of "WATCH LiST"
in java code: actionBar.setCustomView(R.layout.custom_actionbar_layout)
a very late answer, but this is possible. You just have to replace (programatically) the view that is pointed by android.R.id.action_bar_title with a Spinner. I wrote a blog about it. Here's the link

Custom title bar vs. layout with header

I recently thought of adding a custom title bar to my app (with "find me" and home button and such) and then I thought what is the reason of using a custom title bar at top instead of just a normal layout and using it as an include tag at the top of my XML's
What are the pros and cons of each? Is there realy a difference?
EDIT: one difference ive found so far is that the custom title bar has a shadows automaticly
For having back and home button titlebar, you should define normal layout for the same. Because it is easy to implement as compared to customized the native title bar. And we can create normal layout as we wants with any color/height/width/image backround/etc.
I suggest you to go with defining normal layout for the title bar instead of customizing the native title bar.
You can extend LinearLayout to create a new layout with your title bar. The advantage is you can then customise the title bar for different activities that use it. Some may not want to display the find button for instance.
If you use include in XML you don't have the same flexibility.
I would create a custom layout with the title bar.

Spinner pop up window title background

I would like to modify the background of the title bar of the dropdown dialog associated to a spinner.
If this is not possible I would like to know what resource is used to draw this background android.R.drawable.* ?
This is an effort of uniformity for my various pop ups in my application.
You can change everything using styles and themes.
Take a look at this example for buttons:
http://blog.androgames.net/40/custom-button-style-and-theme/

Categories

Resources