I am using the appcompat support library and I want to change the color of the action bar tabs. I found these instructions in which the customize tab indicator section suggests creating a file res/drawable/actionbar_tab_indicator.xml declaring a specific background image for several different states of an action bar tab.
actionbar_tab_indicator.xml looks like :
<!-- STATES WHEN BUTTON IS NOT PRESSED -->
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false"
android:state_pressed="false"
android:drawable="#drawable/tab_unselected" />
...
The #drawable/* images are nine patches.
However, i do not want to get involved in creating nine-patches images. Is there another way to change the actionbar tab's color?
I wrote an answer to that question 1 year ago.
You can find in here:
Change Color TabSelector on v4 ViewPager
How can I create a settings menu for my application that let's me show more information about the current status? With the menu layout it appears that I can only set these attributes:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/bot_engine"
android:title="#string/menu_settings_bot_engine" />
<item
android:id="#+id/text_to_speech"
android:title="#string/menu_settings_text_speech" />
</menu>
And It displays as follows:
But I want something like this:
This is how Google Glass display It's settings menu.
I want the user to be able to tab over the settings to toggle them between (Active/Inactive), displaying a message:
Active (In green) or Inactive (in red).
How can I do that?
The GDK menu works in the same way as the android context menu's on a phone.
It's designed for simple menus with just text and an optional icon. If you want to do something more complex (Like the glass settings) you would need to use a CardScrollView and add your own cards to it, then you can have as much flexibility as you like.
Hope that helps.
I would like to write under the text in the action bar so i use this xml:
<item
android:id="#+id/Home"
android:icon="#drawable/ic_action_home"
android:showAsAction="always|withText"
android:title="home"/>
<item
android:id="#+id/Refresh"
android:icon="#drawable/ic_action_refresh"
android:orderInCategory="100"
android:showAsAction="always|withText"
android:title="refresh"/>
although i write:
android:showAsAction="always|withText"
this what i get :
How could I write text under the icons ?
'always|withText' only works if there is sufficient room. Else, it will only place icon. In your case, you've got several icons there which does not leave any spare room for text.
You've got two options:
Reduce the icons by moving them either to an overflow menu or somewhere else in your UI.
Design images which consist both icon and text and use them as your icons.
Edit: Well, here's a lot better answer: https://stackoverflow.com/a/12225863/2511884
I have a sliding drawer menu in an activity, which has an actionbar with some tabs on it.
I'd like to get the sliding drawer to slide over the tabs , not below them.
This is what it looks like right now...
Any ideas on how this could be done?
Note: I understand that I might be breaking some conventions and UI patterns here, and if it does not work at all, I'll look at alternatives. But I'd like to get this working first.
EDIT: See the below screen shot of the Google Play Music app that does exactly what I need. See #CommonsWare's answer below where he does agree that I might be breaking convention. But then given the Play Music app, it may not be altogether that rare either.
you can use below libraries to get navigation model similar to Google play music app.
ActionBarSherlock (github)
nested-fragments (github)
PagerSlidingTabStrip (github)
NavigationDrawer (Android developer site)
Latest Support v4 library
I have created a project Navigation Drawer with Tab Strip Example at github, have a look at it.
Below is the screenshot of it.
Any ideas on how this could be done?
Do any of the following:
Switch away from action bar tabs, perhaps to ViewPager and a tabbed indicator (PagerTabStrip, TabPageIndicator from ViewPageIndicator)
See if an existing third-party drawer implementation has not yet updated to the new UI standards
Fork DrawerLayout and modify it to suit
Roll your own navigation drawer from scratch
I understand that I might be breaking some conventions and UI patterns here
Correct.
Check also this library http://www.androidviews.net/2013/04/pager-sliding-tabstrip/
The guy did a great job. You can use it with a navigation drawer and it works perfectly.
Finally, a clean way to achieve navigation drawer over sliding tabs in this blog
http://www.paulusworld.com/technical/android-navigationdrawer-sliding-tabs
This can be done WITHOUT a Third party library. Check out Google's Sliding Tabs samples
SlidingTabsBasic: http://developer.android.com/samples/SlidingTabsBasic/project.html
SlidingTabsColors: http://developer.android.com/samples/SlidingTabsColors/project.html
Also, check out this awesome link: http://manishkpr.webheavens.com/android-sliding-tabs-example/
Worked like a charm for me. :)
I had the same problem, but the only solution I found was to use tabs inside the inner fragment (not fragmentActivity). I don't know if it was the best solution, the only problem i had was styling this tabs, for the rest, it works perfectly
I managed to achieve this requirement by setting the navigationMode inside OnDrawerClosed and onDrawerOpened functions. It is a temp fix since the tabs actually do not disappear immediately.
public void onDrawerClosed(View view) {
getActionBar().setTitle(mTitle);
if(getActionBar().getTabCount()>0) //Add tabs when the fragment has it
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
...
}
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle(mDrawerTitle);
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
..
}
If you have some fragments with tabs, and other without it don't forget to remove tabs onCreateView of fragment that does not have tabs.
getActionBar().removeAllTabs();
Actionbar Navigaton Drawer and SwipeTabs cant be used simultaneously. You should implement Navigation Drawer using Actionbar and swipetabs by simple Tabhosts. You can use Tabhost for tabs and use fragments for inside view of each Tab. Fragments should be used via viewpager to provide scrolling/swiping effect. Connect tabs and viewpager with eachother through their methods
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabHost
android:id="#+id/tabHost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="none" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TabWidget>
</HorizontalScrollView>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.view.ViewPager
android:id="#+id/viewPager_home"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
</LinearLayout>
</TabHost>
Play music does not use standard ActionBar.Tab
Then you can implement your own tab container by extend HorizontalScrollView
and work together with ViewPager
I have use tabs inside fragment of drawer.
I solve this problem adding
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
in onDrawerClosed() and getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); in onDrawerOpend() method.
I hope this will help you.
Is there a way to customize the size of this widget? My client wants it in the header but it's too big.
(source: google.com)
This is the embed code they offer for a WordPress widget. There must be a way to cause an onclick of a custom image to trigger this?
<object type="application/x-shockwave-flash" data="https://clients4.google.com/voice/embed/webCallButton" width="230" height="85">
<param name="movie" value="https://clients4.google.com/voice/embed/webCallButton" />
<param name="wmode" value="transparent" />
<param name="FlashVars" value="id=#####numberhidden####&style=0" /></object>
I was able to find this link which doesn't exactly let you resize it but it's a way to push the variables that Google needs in a custom format through input fields.
http://razvangavril.com/web-development/custom-google-voice-widget/
and
http://razvangavril.com/web-development/custom-google-voice-widget-2/
The ButID label for button_id part is a text field where you enter your Google Voice ID. You can find that in their embed code by looking for ID=. I chose to make it a hidden field, and manually insert mine.
The other two fields are your name, and phone number. You then insert their script with the form, customize the look, and you're done.
Thank you!
Using the tutorial from:
http://razvangavril.com/web-development/custom-google-voice-widget/
You could create a button or image of any kind and have that throw a dialog box with your call form.