Can I control a horizontal linear layout by pressing the menu button on android? I basically want the layout to be invisible until the menu button on the phone is pressed which brings up the layout on the screen.
Thanks,
Ab
Look into View stubs, that may do what you need. You can set the layout to invisible in xml, and in code where need make them visible.
Related
I have a menu with checkable items. I want to put the CheckBox first and the Text to the right of the CheckBox. Any idea how to do this?
It's not possible to do this using menu items. What you can do, is use a custom Toolbar with a custom ImageView(aligned right) with the image src as the overflow icon (the one with 3 vertical dots). Also create a custom view(let's say checkBoxList) in your layout, which contains the text to the right of checkbox, the way you want it. Keep this checkBoxList aligned to the top right of your parent layout (super easy if you are using ConstraintLayout). Also, keep the visibility of this List to invisible. When overflow icon get's clicked, set the visibility of checkBoxList to visible. Also, have an onClickListener on the parent Layout, where you set the visibility of checkBoxList back to invisible( So that when the user clicks on anywhere outside checkBoxList, it closes).
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've followed this guide to make the sliding menu like the facebook app has.
When the Button is pressed, a new Layout shows from the left of the screen. But it pushes the orginal Layout with elements to the right of the screen. How can I make the Layout lay over the orginal Layout?
See the link for code samples. Thanks!
Let me rephrase my question
When I press the button, the text of the button, and the button itself will be pushed to one side, and aligned vertically. How can I just push the button "out of the screen"
To overlap layout/views above each other, you need to use FrameLayout. It sets the visibility of view (e.g. z-index in CSS) in the order as they are defined.
Sounds like you are adding the new layout to the parent layout which is why its pushing the original layout out of the way. You need to add the new layout to the original layout and it will lay in the original layout.
I have an activity where the view is like a form, where user can enter the details and At the bottom there are two buttons "save" and "cancel". The form has many number of edit boxes.
So I have taken a relative layout and put all these edit boxes in it and then put the relative layout inside scroll view. I have taken another relative layout to add "Save" and "cancel" button.
Finally I have put the scroll view and relative layout(which has buttons) in another relative layout which is the main view of my activity.
My problem is , when I click any of the edit box, keyboard will come up and it hides the buttons(Save and Cancel).
I want to make the buttons to display above the keyboard(When the keyboard is on) like in the edit contact activity of "Contacts" Application .
I am using android:windowSoftInputMode="adjustPan|adjustResize" for my activity but of no use.
I have gone through so many stack overflow questions regarding this but I am not able to achieve this.
How can I do this with my code?
in Edit Contact activity save button is added to layout in bottom, and outside of scroll view.
What you can do, to make your save and cancel button visible all the time, wheather, soft keyboard is visible, or not. Make parent layout a relativelayout, in this layout add two views one scroll view, and other relativelayout having buttons. Let Relative Layout properties layout_width=fill_parent and layout_height=wrap_content, and align_parent_bottom=true, and scroll view's layout_width=fill_parent, layout_height=fill_parent, lavout_above=#+id/rlButtons, in ScrollView, add a RelativeLayout having all the editTexts.
I got the solution .
My parent layout is Relative Layout . In this layout I added a Scroll View and a relative layout. In the scroll view I added a relative layout which is having all edit texts. In relative layout I added save and cancel buttons. I set the scroll view weight = 1.
For my activity I set android:windowSoftInputMode="adjustResize".
In my app I want to have a button that if the user clicks it
than a new layout is opened within the current (acually the main) layout.
the new layout should not fill all of the screen and parts of the previous layout
should be grayed out.
Any ideas on how to do this ?
You can show a hidden layout within your button's onClick event by calling
view.setVisibility(View.VISIBLE)
You can also fade out view elements or whole views with
view.setAlpha(75);
view.setBackgroundColor(Color.GRAY);
Note that "view" in the first example is your layout element.. LinearLayout, RelativeLayout, etc. and in the 2nd example, "view" is the element(s) you're trying to gray out.
Follow the answer of SBerg413. And for more information. you can take the relativelayout for the part that you want to hide and display on the button click.
And as like SBerg413 answer. you can hide the respective layout and show the layout you want to display.
Hope it will help you.
Thanks.
you can use a ViewFlipper to achieve what you want, position the viewflipper where the child views should fit (part of the screen you say)..
Inflate the rest of the "child" layouts from other xml, add them to the flipper and switch between them when you want...