Any better approach for layout design? - android

just wondering if anyone else has a better suggestion that what I'm coming up with.
The issue is to do with a TabLayout, 5 Tabs all using a single Activity. Each Tab layout contains quite a few fields so the main parent on each tab is a ScrollView.
What I currently have is a 'Save' & 'Cancel' button sitting outside the scrollviews so theyre always visible and there for the user regardless which tab they're on. The problem is that since I'm using Tabs and always have these buttons visible when they are editing and the IME is displayed, they'res barely any of the form visible.
So I think the best thing for me to do is to probably show the buttons at the end of each scrollview. What I don't like about this is as I have 5 tabs, it will mean I have to declare 5 sets of the buttons, and of course define them and bind them in the Activity.. which seems rather messy and inefficient.
So if anyone has any better ideas I sure would love to hear them :-)
Thanks
Rgds,
Dave

Some of the options you got is
Try to put a title bar, and move the save and cancel buttons there (Small image buttons).
Save can be moved to the menu too (not recommended).
Auto Save functionality can also help, depends on how useful is it to you.
Try to use custom images for tabs, and make it take less space.
else, remove the save and cancel buttons, after the user makes any modifications, and presses back, prompt him to save the unsaved changes.

You could make it that when you're in tab X, the tab button for tab X now becomes X(save), so if they click again on the tab button in the same tab, it saves. That saves you five buttons, potentially...

Define programmatically the buttons inside a LinearLayout and add them to each ScrollView with addView. The code of the buttons should check in what tab are we at that moment, and act accordingly.
Then you'll have the same two buttons arranged in the same way in all your ScrollViews.
Or, if you dislike doing it programmatically, do a layout for the buttons and use View.inflate of that layout, and add them via addView to the ScrollView.

Related

how to make a button fold down two EditTexts below on click

I'm a beginner with short knowledge of programming, I've just started learning android development. I'm making an app and at one of the pages I have to make a certain kind of design that I cannot figure out how to or can't even find them in the internet. Basically, as you can see in the images below, next to the first textview, there's a little arrow. Whenever the user clicks on that arrow, two edittexts should appear below that texview just like in the second image and kind of drag the rest of the textviews down. I'd be really grateful if you guys could help me do this or at least provide me with some information on where to search this kind of problem solution. Thanks.
Just create your desired layout in xml with 2 edittext below each textview. But make sure You take these 2 edittexts in a single container. Lets say LinearLayout.
Then you would be easily able to show/hide these lineralayout based on the TextView click.
Or If You are using recyclerView, then it would be more easy. In this case, You have to show the 2 edittexts for currently clicked item only and will need to hide for all others

How to connect the Buttons UI?

I struck in Materiel Design and need to connect those two button like the image mentioned below and when i clicked the any one button only the layout should change not the activity, so I googled for this solution but i didn't found any.Could anyone suggest me some possible solutions to achieve this UI.
You want to keep the 2 buttons and a line in buttons as well if that is the case.
Use 2 buttons widgets and keep a view between them as for lining purpose. And fro your question one button only the layout should change not the activity
You can try fragments. On clicking any of the buttons change fragment
you are suppose to use Fragment with viewpager!
you just disable viewpager swipe by this mViewPager.setPagingEnabled(false);
and setSelection when clicked on item
here is a cool library to implement this.Step view

2 LinearLayouts in the same position

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. :)

Replacing views dynamically without changing activity

I would like to know how to go about doing this small problem that I am encountering while making a video player app.
On clicking the first control(the rectangular icon) in the above image the following view must be displayed instead of it which I am quite unsure as to how to do it. Here is what it is replaced by
Also please note, by any chance the activity should not be changed. I have been able to design the views individually but having problem changing them at runtime when user clicks. Could someone go about explaining as to how it can be done or provide some suitable links to achieve my goal. Thanks.
For something as simple as this you can just change the visibility of the views.
view.setVisibility(View.INVISIBLE)
Or the more effective:
view.setVisibility(View.GONE)
Do that on the views you want gone, I suggest a wrapper class. It's either this or changing the contentView as describded below.
this.setContentView(R.layout.newLayoutToUse);
However, I have a feeling there is a better way to do what you want. It's overkill to load a complete new layout if you just want to change the image of some buttons or imageviews.
This might be a stupid solution, 'cause i'm terribly tired right now, but why not use the bringToFront() method on the View that you want to display in the front? Display them both in front of each other, maybe in a RelativeLayout, and then swap between them as you wish.
They are small objects, so don't consume memory. I don't see why this shouldn't work.
OR
Place them above one another, so they overlap and then make the above view visible/invisible depending on which one you need to display.
OR
just remembered I read somewhere that you can scroll through a ScrollView automatically from code. So display both Views in a ScrollView in succession and when pressing the button or whatever, you scroll down to make the next menu visible. When pres back, you scroll up to make the previous thing available. Should work, and might also make a nice animation between changing of the menus.

FrameLayout buttons overlap, and can't be 'touched. - what's right way to access?

I'm using a FrameLayout and have two buttons on it, button A and button B (in addition to some other widgets). A is directly on top of B, overlapping completely.
In onCreate, I do a check and if A is not needed, I set it to invisible. Later in the app it may become visible again so I don't want to remove it completely.
When button B is pressed, it doesn't respond. I think button A is stopping the press even though it's invisible. Other buttons do respond so this is why I think this.
Is there a common way to make it so B accepts touches? Do I have to remove A? I don't really want to remove A as I have a relative layout in the frame layout and other controls depend on A for positioning.
Personally I think it would make a lot more sense to have a single button who's properties vary based on configuration. However, if you really want to have two, you could try a couple of things:
Set the invisible button to not be focusable or touchable.
Set the button to Gone, not invisible. This might mess up the layout though, since this basically says not to consider the button when doing the layout.

Categories

Resources