I'm trying to center a view on my ActionBar, relative to the overall width. The code I have at the moment:
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(R.layout.action_bar_custom);
sets a linear layout with centered gravity in the middle of the Home button and the Menu buttons, instead of directly in the middle of the Action Bar. Some fragments have menu options and some don't, which need to be there.
How would I achieve this?
Examples of what is currently happening:
Related
I want to have a tool bar on top and another bar at bottom of my activity,
make it look like that:
you can use Bottom navigation bars.
https://www.google.com/design/spec/components/bottom-navigation.html
Create a linear layout and align layout on top. For bottom, create another linear layout and align layout to bottom. Add your views into the layouts.
I'm using the Toolbar widget of appcompat v21.
Without hiding the toolbar title I want to add some views (ie: textview, button) to the content of the toolbar.
By default they are positioned to the left, but I need to put them to the right. I managed to do it with a RelativeLayout. The problem is that the RelativeLayout takes all the toolbar's space and the title is not visible anymore.
There is a way to do it without hide the title?
I have a custom layout which includes three buttons which in have included in layout at bottom i want to Show and hide custom layout on click in android bottom of layout with slide up and slide down an scaling animation in android.
I wanna create a menu that be seen when clicked on the center of screen like Aldiko.
I've tested PopupWindow for create menu items but I didn't any solution for trackbar.
Are there any solutions?
Using Default Menu you can create Bottom or TOP layout. So you cant used this. But you can create your own layouts. Align one layout to top & second to bottom. Initially did INVISIBLE both layouts, when you click on center then VISIBLE both layouts.
You can use split ActionBar for getting something like you want. The only repercussion of using it will be the look in different screen modes (portrait and landscape). Your action items will align themselves as per the available screen space. Let me know if you are looking for some code for doing it with ActionBar.
You can use FrameLayout and put the main app layout on back frame and menu (with transparent background) on the top frame. Initial set the visibility of the menu layout to invisible so you app main layout would only be visible. Now when you clicks on the main layout just change the visibility to visible, when user press again set the top layout again to invisible.
I am having a sliding drawer positioned at the bottom . and below that I have a linear layout of 50dp .
So my layout looks like this :
Where red rectangle is the sliding drawer handle
Now when I slide my finger from bottom of the screen to the sliding drawer , i.e. along the blue path
The sliding drawer doesn't open . It doesn't open because the click activity is captured by the bottom layout.
The sliding drawer opens only when I click EXACTLY within the red rectangle.
I tried making the bottom layout clickable=>false focussable=>false still no good.
Any idea on how can I make the click event of bottom layout loose its click as soon as the finger is out of the layout ? , so that the handle can capture the click
I would suggest you to create the entire linear layout (brown bottom bar) as handler for your drawer. Doing so will allow you to slide the drawer as you want in the second picture.
Or, alternatively, you can make use of FrameLayout to present LinearLayout and drawer's view as with in a single layout and set the width and height of your drawer as linear layout - covering the entire area of linear layout.
Or, at last, implement SimpleOnGestureListener on linearlayout (for upwards direction) to execute drawer's click action.
You said you tried clickable=false and focusable=false... did you also set focusableintouchmode=false? (I would set all three and see what happens).
As I painfully discovered recently, focusable-false only covers the hardware, not the touch screen. I had to add focusableintouchmode="false".. maybe that will work for you too.