My AdView banner is constraint to bottom of parent. There is no issue with it so long as I do not start my Intent SQLView. After calling SQLView and returning to Main Activity, the banner will move according with the keyboard. Please refer to images attached. Attach part of my code below, do let me know if more parts are needed and I will add accordingly. Thanks!
Main Activity
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713");
btnView = findViewById(R.id.buttonView);
bannerAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
bannerAdView.loadAd(adRequest);
btnView.setOnClickListener(this);
}
@Override
public void onClick(View arg0) {
switch (arg0.getId()){
case R.id.buttonSetBudget:
setBudgetDialog();
break;
case R.id.buttonSave:
...
break;
case R.id.buttonView:
Intent i = new Intent(this, SQLView.class);
startActivity(i);
break;
case R.id.buttonExport:
...
break;
}
}
SQLView
public class SQLView extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
Button backButton = findViewById(R.id.buttonBack);
...
backButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
}
main_activity.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorColumnOne"
android:orientation="vertical"
android:paddingLeft="5dp"
android:paddingRight="5dp"
tools:context=".MainActivity">
...
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="8dp"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111"
ads:layout_constraintBottom_toBottomOf="parent"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintHorizontal_bias="0.5"
ads:layout_constraintStart_toStartOf="parent">
</com.google.android.gms.ads.AdView>