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.
Related
I want to place a toolbar at the bottom similar to the below, sample post compose, screenshot highlighted in green.
But the toolbar should be pushed up when the keypad comes up while entering text as below sample screenshot.
I can design the button toolbar, but no idea how to make it always visible when using keypad. Request to provide sample code for achieving this.
There are two modes for how Android can display the screen with the keyboard up- resize or pan. In pan, the application is scrolled up such that the cursor is assured to be on the page. In resize, the app is resized to fill the space left after the keyboard isplays.
You want resize. But that's not sufficient. Your layout for the screen needs to be such that the toolbar is fixed to the bottom of the screen and that the stuff above it is flexible in size. The best way to do this is to use a RelativeLayout or ConstraintLayout for the root, and to put the toolbar to align to the parent on its bottom. Make that top bar with the post button do the same with the top. Then have the stuff between them be fill_parent and have it layout below the top bar and above the bottom bar.
The end result of all that is that the top and bottom bars will be put in a fixed position, and the center part will be laid out inbetween. Note that this could result in some elements not appearing on screen until the keyboard is dismissed, because they won't fit. Putting the contents in a ScrollView can mitigate that problem, so the user could scroll to it.
I have an application in which i want to hide the android status bar and make my application fullscreen. I have a set of indicator icons shown at the top row in a horizontal linear layout with a downward arrow at the middle of the view. On dragging the arrow down, i want to resize the view and show some detailed information of the indicators. This overlay should be pulled down above whatever existing content is present in my application till 50% of the height with the bottom background content losing focus and getting blurred. Something similar to the Status bar and Quick Settings overlay of SystemUI aosp application. How can i achieve this??
I am using a BottomSheet in my application, which contain some list items, and I am also using a Tab bar view in my whole application (at bottom of screen).
Is it possible and how can I display my that Tab Bar still in bottom of screen, and BottomSheet should also appear (on defined offset), but below my Tab Bar.
How can I adjust and arrange these layouts?
Please show Below link. Also you can add multiple tab bar in bottom layout.
https://material.io/design/components/bottom-navigation.html
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.
I want my ActionBar to act like it does in the stock/default Android browser:
It visible at the top of the page, but as the user scrolls down, the bar scrolls out of view, how ever if you scroll the page upward towards the top, the bar comes in to view again, but will hide after some time out, when it does this, it does not affect the underlying view.
I've tried implementing auto-hiding using timers but when the ActionBar hides, it moves up the scrollable view underneath so it looks as is my whole page shifts up instead of the ActionBar floating over the top of the view.
You are looking for the action bar overlay mode in combination with the Quick Return pattern. That is the feature, where a view becomes visible on top again when the user scrolls up a little. See this excellent blog post describing this pattern. Don't miss the example implementation by Roman Nurik from Google.
Enable the overlay mode by requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY) before setContentView() or by setting the theme attribute android:windowActionBarOverlay to true.
Did you try the overlay mode on the ActionBar, getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY)?
Then add a marginTop to your main layout.