0

​I am developing an Android application that has a ListView containing CardViews populated using a custom ArrayAdapter .

The CardViews have an expandable area that becomes visible on click by sliding downward .​​

However when i view the last CardView that is visible on the screen i can only see the non-expandable part of the CardView i.e. the expandable can only be viewed if i scroll downward myself.

I have seen this type of feature before where the layout automatically adjusts by scrolling downward to include the expandable part .

I have not been able to implement this myself .

How can i achieve this functionality ?

hajas
  • 113
  • 1
  • 6

1 Answers1

0

if you are using scrollview as wrapper over your content inside CardView. You can use

mScrollView.post(new Runnable() { 
    public void run() { 
         mScrollView.scrollTo(0, mScrollView.getBottom());
    } 
});

or

mScrollView.post(new Runnable() { 
    public void run() { 
         mScrollView.fullScroll(mScrollView.FOCUS_DOWN);
    } 
});

above two codes are from question Can I scroll a ScrollView programmatically in Android?

also try

scrollView.scrollTo(0, TextView.getBottom());

where textview is at bottom of your cardview

else you can try using

yourview.fullscroll(yourview.FOCUS_DOWN);

if thats even possible

  • I have used a list view of card views so if i use "scrollview as wrapper over my content inside CardView" it doesnt have any influence over the scroll of activity . – hajas Jun 19 '18 at 20:30