I have two layouts, manageLayout and mainLayout. They have constraints to the parent on all sides. I need in a one time have manageLayout on the top of mainLayout, and on the other time mainLayout on the top of manageLayout. Of course, there is sense in using visibility=gone on one of them, but i need one layout on the background of another. Problem: layout on the background handle events from top layout. How to make lower layout(and his elements) untouchable when another layout is risen?
Layout tree image:
LayoutTreeImg
Code sample, where i want to disable communications with lower layout: https://pastebin.com/PeL7u3YD (not only isSaveEnabled=false had no effect, also isEnabled=false had no effects too)
If you just need an explanation.
Once you've initialized both your views for mainLayout and manageLayout, you will need to set an empty onClickListener on both of them. Basically, layouts should get the click but do nothing. This way you can block the layout and widgets underneath the view on Front from getting clicked.
Now for for switching view to front maintain a boolean to know which view is on the front and on your button click set the other view bringToFront() (Or try some other ways mentioned here if you want) and don't forget to switch the boolean value.
Let me know if this works for you or you have any issues regarding this.
According to my perception, you can make lower layout setEnable(false). I hope it will work.
Related
When I set setVisibility(View.GONE) or setVisibility(View.VISIBLE) for a linear layout it seems that it does not changes the visibility of the view(saying view group would be more accurate). At various post in SO, it has been suggested that get the count for the particular linear layout and change the visibility of each child one by one. Well that can work but it also increases the time taken to process that piece of code. And when there are various view involve, it will be increase to many folds. Same goes for setEnabled(true) or setEnabled(false).
My question is there a alternative for this, as directly changing the visibility is definitely not working? And if not can anybody explain to me why android choose to keep it this way, i.e developer cannot directly change the state(visibility/enabling) of the view group.
I would work with a piece of layout that isn't shown, the user must scroll to see what I have did. How can I do it? Can I join 2 different layout in one? I prefer to collocate item as I do with default layout. If it can help, I use Android studio. I prefer use elements without code, adding them from palette. An example :
You can use two different layout in main relative layout & whenever u want child layout just set visibility.
You will want to use a ScrollView for this. From the documentation:
Layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display.
Well, i am developing new features inside a product which means lots of limitations i just can't break.
There is one activity which monitor the rotation event but use one unified layout for both portrait and landscape. Now i need to add some animations for several widgets inside the view.
For example, animation A to expand a toolbar, while B to collapse it.
But when i do A in landscape mode, and then rotate to portrait mode, the widgets still keep the position after animation A instead of the original layout configured in the xml file.
So what i want is to reset the layout partially. How can i achieve it???
Thanks!
Finally, i found a solution. Well may be not the best, it still solve my problem.
Insert a parent layout inside the activity view, let's say and put nothing inside it.
During the run time, add the child view according to the screen orientation dynamically as following:
Put the codes inside the onConfigurationChanged().
LinearLayout ll = (LinearLayout)findViewById(R.id.linearlayoutId);
View viewPor/viewLand = getLayoutInfalter().Infalte(R.layout.Por/Land, null);
ll.addView(viewPor/viewLand);
You may need a object associated with the specific view for manipulating the widgets inside the view for the animations.
So what I am trying to do is to have 2 invisible LinearLayouts with buttons they will be from the start to the screen.
On the onClick event one of them will appear with a translate animation,when the other is invisible and then on the other onClick event to close the open one and open the new one.
It will look similar to a sliding menu with the animation.
I want to know how the xml will look like in order to do that.
If it's possible with other layout (RelativeLayout), I also want to know.
Any tips on that?
There are multiple ways to achieve it.
Relative Layout definitely being the one as you your self know. :)
Add both the LinearLayouts with layout_width="match_parent" and layout_height="match_parent" and then toggle between them using setVisibility(View.GONE) and setVisibility(View.VISIBLE). Since View.GONE will remove one Linear Layout the other one will occupy the entire screen in its absence and vice versa.
You can also use FrameLayout. This by default places its children on top of each other.
Suit yourself. :)
I am using Eclipse and a ViewFlipper. In Graphical Layout, I want to see the second, third, and forth layouts of my views - right now, I can only see the first view. Any suggestions?
If I'm understanding you correctly, you want to see each view in the 'Graphical layout' tool? The way I do this, is instead of having all the layout work done in one xml (where your viewflipper is) I make each view a new layout xml. And then have each view (xml file) included into the view flipper by using this....
<include
layout="#layout/layout_media"
android:id="#+id/flipper_media" />
Hope this helps.
just put each layout in relative layout or linear what ever you are working with then with each layout you will work with the first one in the order and etc.. then at the end put each layout in the order you want later
I had to subclass the ViewSwitcher class to display an indeterminate ProgressBar until data is ready to display in the second view. I used isInEditMode() to determine whether I was actually running the app or just previewing in AS.
You should be able to add a custom attribute to choose which child to display. This might look a bit overkill, but if you happen to already have to subclass your ViewSwitcher or ViewFlipper, i think it is not a big deal.
I will try to put an example later.