how to make the actionbar transparent - android

i am learning actionbar and created an actionbar with tabs .the following image shows the view
!
requestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
ActionBar ab=getActionBar();
ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ab.setBackgroundDrawable(new ColorDrawable(Color.MAGENTA));
ab.addTab(ab.newTab().setText("Popular").setTabListener(this));
ab.addTab(ab.newTab().setText("Latest").setTabListener(this));
ab.addTab(ab.newTab().setText("Nearby").setTabListener(this));
They following are my queries :
the tabs have shifted to a bar below the magenta color bar. is it due to space constraints of mobile.if a wish to add any item to this magenta bar with the tabs below how can add to it and then show the same pattern whether it is mobile or tablet.
i want to make this tabs bar transparent so that i can see the text move behind it.i have tried to set its drawable as per code above but it has only changed of top bar but not the tabs bar.
what is way to have a button on the magenta bar onclicking i have this screen shift to left and show another screen which has some links show up in a way that partly this current screen is also visible.i hope i am able to explain my point.
kindly clarify

Question 1: It's down to device space constraints. The first paragraph in the Android documentation for tabs in the action bar show that if there isn't room it will split the tabs to a separate bar.
http://developer.android.com/guide/topics/ui/actionbar.html#Tabs
Question 2: You need to set the drawable for the background and the stacked background of the action bar to your transparent drawable. (Edit: Links in Ye Lin Aung's comment show how to do that).
Question 3: It sounds like you are looking for a navigation drawer layout arrangement to me. The best place to start on this would be this link:
http://developer.android.com/training/implementing-navigation/nav-drawer.html
Edit: The pattern will work the same for both mobile and tablets (though you may want to have an xml for smaller screens that have a slightly thinner drawer sizes).
The android documentation in the link above states that the drawer width should be set in dp units and that the drawer height matches the parent view. The drawer width should be no more than 320dp so the user can always see a portion of the main content. This should allow most phones to view it in both portrait and landscape and still see some content.

Related

pulling drawer layout from icon at the bottom

Drawer layouts are typically pulled from the action bar, at least per the official docs. Is there a way to have a pull ImageView attached to the bottom of the drawer? So that the user would tap or pull the ImageView to draw out the navigation drawer? I am referring to the docs at http://developer.android.com/training/implementing-navigation/nav-drawer.html#ActionBarIcon
On newer devices you could try to rotate the view. But I don't know if this will work. See this answer Android:How to rotate LinearLayout

Do xml statements that center take actionbars into account?

Statements such as android:layout_centerInParent="true", does it center by taking the actionbar into account? Because when I use two backgrounds both of the same height that meet in the middle using a fake view that is centered in the parent, the top baclground loooks squished and I think it might be because of the action bar. Hopefully this picture can show what I mean...
Usually the action bar is placed above the rest of your layout. If you want it to be drawn in front of your layout you have to enable overlay mode. Having that in mind, most probably the vertical center of your layout is the center of the area below the action bar (e.g. the leftmost item in your diagram)
You can find more info about the overlay mode at the end of the Removing the action bar section of the ActionBar dev guide.

Last tab in action bar is cropped, goes off screen

I'm making an Android app using tabs for navigation.
I have a problem with the rendering of the last tab in the action bar; it goes off screen and is cropped (this happens as soon as the number of tabs is too big too fit in the screeen width as far as I can tell).
I'm using the ActionBar.NAVIGATION_MODE_TABS navigation mode.
I haven't been able to find any questions with the same problem, any ideas on how to prevent this behavior?
I have already answer a question like that one : Tab item width in Action Bar (Android)

Android change of ActionBar tab from some width

I have one tough question. I am now playing with design of the Android application and I have the problem with way how the tabs are displaying from some width of display. I use ActionBarSherlock library and ViewPager for tabs.
The problem is that I use yellow color for ActionBar, black for tabs and again yellow for tab indicators, but when I look at the application on wider screen or in landscape mode (I guess approximately from width 400dp) I can't see the indicators, because tabs are hiden in action bar and indicator has exactly the same color. Is there som way how to change color of tab indicators from some display width?
I have tried to do it by making of layout-sw400dp/layout.xml, new 9patche's and new styles, but I can't make it work this way and I think now that it is impossible to do it this way. Do you have any idea how to do this?
Thank you very much in advance.
UPDATE
I have solved it in the following way. I have created folders drawable-w400dp and drawable-land (for ancient phones). Only phones where it will probably be displayed in the wrog way are black berry like androids.
Have you tried using the Action bar style generator. I used this and my tabs have highlights in both orientations http://jgilfelt.github.com/android-actionbarstylegenerator/ it generates 9patches and XML for you

When is the ActionBar with Tabs two lines vs one line layout being used?

I've asked a similar question about the Android ActionBar before: Change ActionBar Tabs background color
I still don't have an answer to the question: when will the two line design/when the one line design used? I've set a custom divider to my tab bar and it's also being used in the horizontal layout. However to create drawables/styles based on the orientation/screen size etc I need to know when which layout is being used. Looking through the Android source it seems they are using the same drawables for both layouts, so that doesn't really help me. The same problem applies when changing the font color of the Tab View.
I fear that it'll be decided in code which format is being used, so there's not really any way around this. Can anyone confirm this? Or is there at least a way to find out in code if the Action bar is one lined or two lined?
Android will stack tabs beneath the action bar when it deems the screen size/orientation to be narrow (like on a normal sized screen in portrait, or on a small sized screen regardless of orientation). Similarly if there are many tabs, in some cases they will appear as a drop-down list in order to ensure the best fit in the action bar.
The Action bar is a highly adaptive UI control. If you are going to use its navigation modes I would strongly suggest not trying to anticipate their configuration or attempt to apply styles that are specific to each one. Your tab drawables will always need to be 9patch anyway because the base action bar height will also vary across orientations and screen sizes (notice its height is slightly smaller in landscape).
That said, you can query the action bar height at runtime using its getHeight() method. This Honeycomb Gallery example included in the SDK uses a bunch of logic in an OnGlobalLayoutListener to ensure that the Fragment layout responds to the various action bar sizes appropriately.

Categories

Resources