Reputation: 41099
I have the following portion of layout in one of my layouts:
.....
<LinearLayout
android:id="@+id/llBottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/llGameInformation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:gravity="center_vertical">
<ImageButton
android:id="@+id/imgBtnVolume"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@drawable/icon_button_selector"
android:src="@drawable/icon_button_sound" />
<!--app:srcCompat="@drawable/icon_button_sound"-->
<me.grantland.widget.AutofitTextView
android:id="@+id/tvGameCardText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/cl_game_screen_card_name_text_color"
android:textSize="30dp"
tools:text="card name"
android:gravity="center"
autofit:minTextSize="22dp"
android:layout_centerInParent="true"
android:textAppearance="@style/TextAppearance.GothamBook"
android:layout_toLeftOf="@+id/imgBtnShowCards"
android:layout_toRightOf="@+id/imgBtnVolume"/>
<ImageButton
android:id="@+id/imgBtnShowCards"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:background="@drawable/icon_button_selector"
app:srcCompat="@drawable/icon_button_view"/>
</RelativeLayout>
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
ads:adSize="FLUID"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
</LinearLayout>
....
As you can understand from it's name llBottom is a LinearLayout
that should be at the bottom of the screen, and it is. In it I have a RelativeLayout
that contains several views and under it I placed an AdView
.
I start the AdView with visibility="gone" and I intend to display it based on sever preferences.
The problem is: While this behaves as intended on Nexus 5X the AdView is removed and llGameInformation is the most lower ViewGroup in the layout, on Galaxy devices on the other side AdView is not visible but still takes up the space, so the llGameInformation has an empty space bellow it.
Does someone know what would be the right way to handle this? so no empty space will be left on all devices?
Upvotes: 0
Views: 1027
Reputation: 32221
You should wrap your AdView with FrameLayout
and set its viability to gone
, it could be that the view change it's visibility on it's own.
If you like to dive deeper or if previous not working, you can write a costume FrameLayout
and see if somebody actually try to change its visibility that is not you, in such case you will be able to debug it and block it, as its your view.
There is no way somebody will be able to change your FrameLayout
viability if you don't like it to.
Upvotes: 1