In my layout, I have two items; an ImageView and a ListView, the ImageView appears on top of the ListView in a LinearLayout. The ImageView displays a logo or a profile image while the ListView displays a list of personal / company info.
Now this is my problem, the ListView scrolls on it's own with the ImageView fixed at the top but I want the ImageView to scroll with the ListView so that it is not fixed statically on top.
How do I do this? Is this possible? And if yes can I see an example. Thanks. :)
Edit: I have considered removing the scroll from the ListView and simply just displaying the items without scroll then I can wrap both the ImageView and ListView inside a ScrollView. However I do not know if this is possible or how I can implement it.
Take NestedScrollView as you parent layout and add a LinearLayout as it's child and add your ImageView and listView as child to this linear layout .
<NestedScrollView>
<LinearLayout>
<ImageView/>
<ListView/>
</LinearLayout>
</NestedScrollView>
Related
I have a Activity with a layout that is a Vertical LinearLayout with a RelativeLayout, ListView, and another RelativeLayout. My problem is if the ListView is longer than the screen, the bottom RelativeLayout will be unreachable. How can I ensure the last RelativeLayout is always at the end of the ListView? Can I make it part of the ListView somehow?
If you want the Bottom RelativeLayout to be fixed use the root element as RelativeLayout and use alignParentBottom = true to bottom RelativeLayout and position ListView below top relative layout and above bottom relativelayout.
if the bottom Relativelayout has to scroll as you scroll listview add it as a footer to the listview.Checkout this on how to add a footer to listview.
i suggest you to use recyclerview instead of ListVIew
I am trying to create a XML template such as the Google Play which implement the use of listview and scroll view as below
<custom scrollview>
<imageview>
<textview>
<static listview> //list of comment
<custom scrollview>
The page is scrollable, but when user touch the listview area, the page become unscrollable, is there a way to make the entire page scrollable with the static listview in it?
Basically, I have a Scroll View and it contains several child inside Linear Layout. Now, I want to show a View constantly on the top of the screen when it is scrolled down.If it is scrolled up everything should be as it was earlier.
Can anyone just help me out? Any help would be appreciated! (Thanks in advance).
Define a ObservableScrollView class entends ScrollView.
Then write your layout xml like this:
<RelativeLayout>
<View/>
<ObservableScrollView>
</ObservableScrollView>
<RelativeLayout>
In ObservableScrollView class,focus on this onScrollChanged function.
Change the visibility of your target view by param 'y'.
I have an Activity where there is a Linear Layout which occupies nearly half of the screen and below that I need to keep a listview which has hold any number of items. Now initially I was doing like this
<ScrollView>
<LinearLayout>
</LinearLayout>
<ListView>
</ListView>
</ScrollView>
But reading all the threads I think it is not really a good idea keeping listview inside Scrollview. Also I am facing a lot of issues like the height of the Listview is not proper.
So how do I keep the layout and listview inside the same activity without using ScrollView?
It is not recommended to include a scrolling View (ListView) inside a ScrollView. What you want to achieve can be done by adding a HeaderView which can be inflated from another XML.
LinearLayout ll = inflater.inflate(R.layout.my_layout, null);
listView.addHeaderView(ll);
I am using a scrollview in which i have added 3 relative layout and a list so the stack is like
Scrollview
Relative Layout
Relative Layout
______ ListView
Relative Layout
Now when i am trying to add entries in listview it is now increasing its height. I have set wrap_content for the height field.
Use only listView and add the relativeLayouts as headers/footers.
Fix the height of listview because you are using scrollview
you can scroll and view that list while scrolling content inside listview.