Trying to show to get two relative layouts to scroll - android

Here is the design for my screen:
The Green border indicates the visible screen.
At first the user would only be able to see relative View 1 and the Scrollview would not do anything.
After the user presses the button to show the 2nd relative view, the 2nd relative goes from invisible to visible and the view is now scrollable (because the screen is extended)
I have nested my layouts as followed
<RelativeLayout>
<ScrollView>
<LinearLayout>
<RelativeLayout1>
<RelativeLayout2>
</ Closing for each layout>
My problem is that my either my Relative View 1 will not stretch to fit the screen or if it does stretch to fit the screen, I will not be able to scroll down to relative view two.
I've tried to play around with match_parent,fill_parent,wrap_content on all different levels but haven't found a solution to my problem. Any suggestions on how I would create fix this?

Your design looks like you wanted to implement something expandable view. Try this Link

Related

Make middle View not push other view outside of bounds

I have multiple TextViews inside a horizontal LinearLayout and i need the middle text view to have ellipse=middle so that when the middle text is long enough, it pushes on both sides but the other views don't go out of bounds, but instead the middle TextView shows the '..."
Here's how it should look.
Setting the items normally, wrap_content for all in a horizontal LinearLayout will make the at ASAP text be pushed outside of the screen on Android (the above screens are from the iOS app).
Any ideas on how to accomplish this? Perhaps with a ConstraintLayout somehow ?!
Yes, i would recommend a ConstraintLayout. Top item to the top of the view, bottom item to thr bottom of the view then the middle item attached to these two views. You could also use barriers.

Scroll linear layout beyond the content

I think that this is a simple question but I can't figure it out, I have a Scroll View with some text inside and it works perfectly, it only enables scrolling when the content doesn't fit into the screen. The thing is that I want to scroll the content no matter if it fits or not until the last line of the text reach the top of the view leaving blank space below and obviously "hiding" the content above it. I don't know if I'm explaining myself very well, thanks in advance!
Add a dummy view with height equal to the height of device's screen beneath your textview in scrollView.

Android ScrollView how to keep component on screen when it scroll to top of the screen?

I have a ScrollView layout like this, for example:
<ScrollView>
<Component1>
<Component2>
<Component3>
<Component4>
...
</ScrollView>
Inside ScrollView I have some components, each of them can be anything like LinearLayout, RelativeLayout, TableRow, ...
Now what I want is I will scroll the view, when the <Component2> reach the top of the screen, it will be keep on the screen and <Component3>, <Component4>... will keep scrolling till the end of page. When I scroll down, <Component2> will only be scrolled when all the <Component3> has became visible. I saw this on an Iphone app and wondered how to achieve this on Android.
I don't know if I describe clearly enough but it is same like this video
http://www.youtube.com/watch?v=jXCrM1rzLZY&feature=player_detailpage#t=71s
When the tabs scrolled up to top, it stay there. And when scrolled down like in 1:36 of that video, it stay there until all the content below has became visible on the screen.
Does anybody know how to do this on Android?
I guess you could create a hidden copy of Component2 in a RelativeLayout that is setVisible(true) when the coordinates of Component2 are lower(Android draws from the top) than the top of the ScrollView. When the coordinates of Component2 are higher than the top of the ScrollView (.getTop()), Component2Copy.setVisible(false).
You may also want to disable them when changing their visibility. Good luck with this.

Android: Keeping Image Visible Throughout Animation

Background:
I have an Activity that comprises four buttons that each take up a quarter of the screen.
It contains a horizontal LinearLayout that is divided in half by two vertical LinearLayouts as shown in the image below:
http://i.stack.imgur.com/P7Wd3.jpg
Desired Effect:
When I touch a button, I would like it to animate and fill up the entire screen.
Issue:
I have accomplished the animation aspect by changing X and Y scales from 1 to 2 onClick.
The problem is, however, that the animated button will not show when it leaves its parent LinearLayout.
Thoughts
I have tried making the non-animated buttons invisible, but the animated button will only show in its parent LinearLayout.
I know this problem would be solved if I had used a single LinearLayout, but I was unable to use the "layout:weight" feature to make each button take up half of both width and length.
So... How should I approach this issue?
I would appreciate any help :)
Try using a single RelativeLayout. Check this post for a nice example. You may have to setVisibility(View.INVISIBLE) for the other buttons.
Alternative:
Construct a RelativeLayout as above but put that as the only child
of a FrameLayout.
When animating a button, remove it from the RelativeLayout and add it to the FrameLayout specifying the gravity in the LayoutParams appropriately. This way the rest of the buttons will also be seen in the background during the animation.

Ensuring 2 linearlayouts that replace each other have the same size

I have a top section for the app which is mainly logo and stuff, and roughly the bottom half is supposed to be buttons.. In the outer container, i have a layout for the logo, and imageView to create a seperator line between the top and bottom and the bottom layout..
The issue is bottom layout has 2 linearlayouts (one of which is hidden initially) first one is just a spinner and the second one is 2 buttons..
I have achieved the "roughly 1/3 of space) by using layout_weights in the top and bottom linear layout (2 and 1 respectively) but when I hide the spinner and show the 2 buttons in the bottom layout in the code, the seperator line is pushed up.. I want it to stay in the same place (like be where it would be after the 2 buttons show up from the get-go so that it doesn't have to move)
I could probably just add some margin to the original one to match it but i feel like that will cause issues in the future on different devices.
How can I accomplish this feat?
I think you might be neglecting to set android:layout_height="0dp" on the LinearLayouts that you set android:layout_weight="1" on. If you do this it should fill the space like you want, and you can do layoutView.setVisibility(View.GONE) and layoutView.setVisibility(View.VISIBLE) to toggle the views.

Categories

Resources