0

I have a layout with a nested scrollview and an adview anchored at the bottom of the layout. When I run the app the adview hides the content at the bottom of the nested scrollview. See picture:

https://i.stack.imgur.com/IVh1y.jpg

My first idea is to figure out the height of the adview to add a Space at the bottom of the nested scrollview with the same height, so that the last content of the scrollview would appear over the adview in this case. But the problem is the layout_height for the Adview is wrap_content and this height thus varies from device to device and I don't know how to get this height for the Space.

Any way to find out this height or a better solution?

Markus Kauppinen
  • 3,025
  • 4
  • 20
  • 30
assensi
  • 352
  • 1
  • 6
  • 17

1 Answers1

0

Thank you @digiwizkid for your reference. Reading that thread I have been able to find a simple solution to my problem that I want to share here.

You override the method onWindowFocusChange and inside it we get a hold of the adview height with .getHeight and pass it to the new LinearLayout.LayoutParams object that Space will get:

@Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);

        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mAdView.getHeight());

        mSpace.setLayoutParams(lp);
}

Other people may need to use another LayoutParams object but in my case I am using a LinearLayout.

assensi
  • 352
  • 1
  • 6
  • 17