Controlling the scroll bar in my Android application - android

I have three linear sub layouts in my activity window in my Android application. Each layout has one scroll bar. My problem is when I am trying scroll in one layout area other layouts scroll bars also activating. Could you please suggest a solution for this?

ONE <scrollView> can hold at max ONE component inside it....... this ONE component can be either a layout holding several other views or further layouts inside it, or it can be a single view.
in order to have 3 separate scrolling linear layouts (meaning scrolling one linearLayout does not affect other LinearLayouts)..... you should have 3 separate <ScrollView> elements - each scrollview containing at max ONE of your THREE linearLayout.
for example:
<ScrollView>
<LinearLayout>
all sub-components of **LinearLayout1** goes here
<LinearLayout>
</ScrollView>
<ScrollView>
<LinearLayout>
all sub-components of **LinearLayout2** goes here
<LinearLayout>
</ScrollView>
<ScrollView>
<LinearLayout>
all sub-components of **LinearLayout3** goes here
<LinearLayout>
</ScrollView>
hope it helps you.

Related

An issue with vertical parent scrollview and two children recycler-view in Android?

I've the following use case -
<ScrollView> // parent
<ContentView/> // content
</ScrollView>
I do not have any access to the parent ScrollView because the library only allows setting the content view. And it doesn't provide any API or reference to modify the attributes of the parent ScrollView. And the content of ContentView is arbitrary in a way that it can take recycler-view, list-view and any other views with scrolling effects.
Because I do not have access to the parent ScrollView, I can't change its property / attributes anyhow. This causes the issue will ill-behaved scrolling. This specially shows the problem when
<ScrollView>
<ContentView>
<LinearLayout orientation=horizonal>
<RecyclerView/>
<RecyclerView/>
</LinearLayout>
<ContentView>
<ScrollView
And this causes two recycler-views to scroll together, while I want individual recycler-view scroll independently.
I was thinking of a solution that I can build a container-view and the children of container-view are agnostic of its ScrollView parent. So that my recycler-views have no knowledge of its parent ScrollView.
Is there any way to implement such solution? Have you ever encountered such an issue and how did you fix it?

How to design 2 different layers in one activity

I'm new at Android programming and couldn't solve how to do a design problem.
I have an activity with constraint layout, and it is full of textviews and buttons.
I want to put 6 imageview tool top of to the this activity. And there should be 3 of them should be seen on the screen, other ones should be scrolls to the right side. Like the screenshot I'm uploading.
Only these 6 imageviews should be scrolling horizontally.
I don't know what to do, which tools should I use. How can I do that design?
Thanks.
For the 6 ImageViews scrolling horizontally, I would advise you make use of a RecyclerView which is very powerful in dealing with showing data in a list especially for very large data sets. You can check out how to work with a RecyclerView here.
Since you only have 6 ImageViews, you can make use of a HorizontalScrollView, a LinearLayout with orientation set to horizontal i.e android:orientation="horizontal" and then place your ImageViews inside the LinearLayout.
<HorizontalScrollView ...........>
<LinearLayout ......>
<ImageView......./>
<ImageView......./>
<ImageView......./>
<ImageView......./>
<ImageView......./>
<ImageView......./>
</LinearLayout>
</HorizontalScrollView>
The easiest solution here is a HorizontalScrollView.
As HorizontalScrollView only accepts one child, wrap your ImageViews in another layout, e.g. LinearLayout or ConstraintLayout, then put that in a HorizontalScrollView.
You can use horizontal recyclerview for imageviews and below horizontal recyclerview, you can use linear layout for textviews inside scroll view.
<ScrollView>
<LinearLayout>
<RecyclerView>
</RecyclerView>
<LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>

Most fitting View/Layout for placing several text- and image views inside, XML for Android

So I have this ScrollView inside which I have a RelativeLayout on one of my views on my Android app. Inside the RelativeLayout I already have a TableLayout that I'm using, and above it I want; 2 different text views (one header and one longer text, and I want the header to be placed on top of the longer bit of text) aswell as an ImageView that I want to be placed to the right of the 2 TextViews, and I want all 3 views to be placed on a differently colored background than the other stuff on the ScrollView such as the TableLayout for example.
I tried putting another RelativeLayout inside the ScrollView but it tells me ScrollView can only host one direct child, so that didn't really pan out. What would the most fitting way to accomplish this? Because I want this 3-view-background-thingie to scroll with the TableLayout and all the other stuff on the view.
As always, thankful for any answers or tips!
(My design kinda looks like this at the moment, schematically;)
<Container (that doesn't scroll)/>
<ScrollView
<RelativeLayout
*Alot of stuff here, such as a TableLayout for example
</RelativeLayout>
</ScrollView>
Put everything in your RelativeLayout
<ScrollView
<RelativeLayout
<LinearLayout>
<TextView>
</TextView>
<TextView>
</TextView>
<ImageView>
</ImageView>
</LinearLayout>
<TableLayout>
</TableLayout>
</RelativeLayout>
</ScrollView>
This way, the only child is the RelativeLayout, the others being children of the RelativeLayout.
Hope this helps!

ScrollView with 2 Buttons which are fixed at the bottom

I just know how to fix two buttons at the bottom of RelativeLayout. But the problem is that small displays can not see everything, so I want to have a scrollLayout but also a Relative Layout so the two buttons are at the bottom of the display every time. Does anyone have an idea how to implement it?
Thanks very much :)
Try it like this:
<LinearLayout>
<ScrollLayout>
<RelativeLayout>
Your content here
</RelativeLayout>
</ScrollLayout>
<RelativeLayout>
Your two buttons here
</RelativeLayout>
</LinearLayout>

ScrollView not displaying some UI elements

I'm developing an application with executes searches via an API on a web server. My search page displays well in portait mode but is too big for landscape mode so I've decided to simply contain all UI elements in a ScrollView by customising the XML in layout-land folder. The problem is, the buttons on the bottom of my form are not being shown in landscape ScrollView. I don't use ScrollView in portrait so maybe that's the problem? The layout XML is like this:
<LinearLayout>
<ScrollView>
<LinearLayout>
<TableLayout>
<!-- stuff here is being shown (table with TextViews and EditTexts -->
</TableLayout>
<LinearLayout>
<!-- stuff here is not being shown (3 Buttons) -->
</LinearLayout>
</LinearLayout>
</ScrollView>
Most likely you forgot to set android:orientation="vertical" to your LinearLayout (direct child of ScrollView).

Categories

Resources