I have one fragment activity. At the top of the fragment I want to place a small advertisement. The problem is that if I define something on top of my fragment, the text inside my fragment will seem to be cut off. Look at the images (before advertising and after).
Before:
After:
Pay attention to the scroll bar at the top, which means that it reduces the visibility of my button.
All I wanted to do was keep the text βJogarβ visible when the ad is visible. Here are some of the xml and code that will help if necessary. Please help me if you have an idea how to fix this.
activity_xml:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#00F"> <com.google.ads.AdView android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" ads:adUnitId="..." ads:adSize="BANNER" ads:testDevices="TEST_EMULATOR" android:background="@android:color/transparent" ads:loadAdOnCreate="true" /> <FrameLayout android:id="@+id/fragmentPlaceholder" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#0F0"/> </LinearLayout>
fragment_xml:
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center"> <Button android:id="@+id/playButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="10dp" android:text="@string/play" style="@style/TextFont"/> <Button android:id="@+id/rankButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/rank" style="@style/TextFont"/> <Button android:id="@+id/achievementsButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/achievements" style="@style/TextFont" /> <Button android:id="@+id/settingsButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/settings" style="@style/TextFont"/> <com.google.android.gms.common.SignInButton android:id="@+id/sign_in_button" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <Button android:id="@+id/sign_out_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:textColor="@android:color/black" android:background="@android:drawable/btn_default" android:text="@string/logout" android:visibility="gone" /> </LinearLayout> </ScrollView>
In the Fragment class, I inflate a call of the form:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.menu_initial, container, false); ...
In the Activity class, I call the fragment with:
fm = getSupportFragmentManager(); if(fm.getBackStackEntryCount() == 0){ initialMenu = new InitialMenu(); fm.beginTransaction().replace(R.id.fragmentPlaceholder, initialMenu, "initialFrag").commit(); }
source share