I've just started with Android and was developing my first app that includes a Login Screen.
Initially, I had used RelativeLayout
and AdView
or any other View was getting correctly placed to the bottom of the parent using android:layout_alignParentBottom="true"
.
Then, while reading about Material Guidelines, I was referring to a XML that used LinearLayout
inside ScrollView
. Now I can't place my AdView
to the bottom most position (try importing this XML to your Android Studio). Searching for answers here, I also placed it inside RelativeLayout
and used android:layout_alignParentBottom="true"
again but no success. I know Android users have played with all this and I hope they can help me.
So, listing my basic questions as:
- Can you tell me the actual use the OP has used
ScrollView
for Login Screen Activity? If you know how to handle UI of the activity, can you just post two or more lines of any tip on what should I use? Any tip would be highly appreciated. - Main Question - So, how do I place
AdView
to the bottom? An explanation would be appreciated.
Thanks. :)
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="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:fitsSystemWindows="true"
android:background="#FFB74D">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="15dp"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:backgroundTintMode="src_atop">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:text="Gyaanify"
android:textSize="55sp"
android:textColor="#FF3D00"
android:textStyle="normal|bold"
android:textAllCaps="false"
android:textAlignment="center"
android:fontFamily="cursive"
android:layout_margin="10dp" />
</RelativeLayout>
<!-- Email Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp">
<EditText android:id="@+id/etUserName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:hint="Email" />
</android.support.design.widget.TextInputLayout>
<!-- Password Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp">
<EditText android:id="@+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:hint="Password"/>
</android.support.design.widget.TextInputLayout>
<android.support.v7.widget.AppCompatButton
android:id="@+id/btn_login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginBottom="24dp"
android:padding="20dp"
android:text="Login"
android:onClick="OnLogin"
android:background="#EF6C00"
android:textColor="@android:color/background_light" />
<TextView android:id="@+id/link_signup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="No account yet? Create one"
android:gravity="center"
android:textSize="16dip"
android:layout_marginTop="40dp" />
<android.support.v7.widget.AppCompatButton
android:id="@+id/btn_register"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:text="Register @ Gyaanify"
android:onClick="OnRegister"
android:padding="20dp"
android:layout_marginTop="10dp"
android:background="#EF6C00"
android:textColor="@android:color/background_light" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:orientation="vertical"
android:layout_alignParentBottom="true">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
</LinearLayout>
</ScrollView>