Search code examples
javaandroidxmlandroid-linearlayout

Parent_Bottom Not working


I am trying to display admob banner in one of my android application. It have many layout in it like LinearLayout etc. I am trying to display it in bottom of screen but layout_alignParentBottom is not working in it. Please check my code and let me know what is wrong in it.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/linearLayout"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:background="#fff8f9fe"
    android:gravity="center"
    android:orientation="vertical">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary"
        android:elevation="6dp"
        android:minHeight="?attr/actionBarSize">

    </android.support.v7.widget.Toolbar>

    <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:local="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/drawerLayout"

        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">


            <ScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center_vertical"
                android:background="@color/main_layout_background_color">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:background="@android:color/transparent"
                    android:gravity="center"
                    android:orientation="vertical">

                    <io.codetail.widget.RevealFrameLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <LinearLayout
                            android:id="@+id/mainLayout"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:background="@android:color/transparent"
                            android:gravity="center"
                            android:orientation="vertical">

                            <ImageView
                                android:id="@+id/txtplay1"
                                android:layout_width="@dimen/activity_main_button_width"
                                android:layout_height="@dimen/activity_main_button_height"
                                android:layout_margin="4dp"
                                android:background="@drawable/play_btn"
                                android:gravity="center"

                                android:typeface="sans" />

                            <ImageView
                                android:id="@+id/favoriteTxt"
                                android:layout_width="@dimen/activity_main_button_width"
                                android:layout_height="@dimen/activity_main_button_height"
                                android:layout_margin="2dp"
                                android:background="@drawable/favorite"
                                android:gravity="center"
                                android:textColor="@color/Black" />

                            <ImageView
                                android:id="@+id/learnTxt"
                                android:layout_width="@dimen/activity_main_button_width"
                                android:layout_height="@dimen/activity_main_button_height"
                                android:layout_margin="2dp"
                                android:background="@drawable/learn"
                                android:gravity="center"
                                android:textColor="@color/Black"
                                android:textSize="35sp"
                                android:typeface="sans" />

                            <ImageView
                                android:id="@+id/txthighscore"
                                android:layout_width="@dimen/activity_main_button_width"
                                android:layout_height="@dimen/activity_main_button_height"
                                android:layout_alignParentLeft="true"
                                android:layout_below="@+id/txtfeedback1"
                                android:layout_margin="2dp"
                                android:background="@drawable/highscore_btn"
                                android:gravity="center"
                                android:padding="10dp"
                                android:textColor="@android:color/white"
                                android:typeface="sans" />

                            <TextView
                                android:id="@+id/btnshopping"
                                android:layout_width="05dp"
                                android:layout_height="05dp"
                                android:layout_alignParentLeft="true"
                                android:layout_below="@+id/txtfeedback1"
                                android:layout_margin="0dp"
                                android:background="@drawable/shopping"
                                android:gravity="center"
                                android:padding="10dp"
                                android:textColor="@android:color/white"
                                android:typeface="sans" />

                            <ImageView
                                android:id="@+id/txtcontest"
                                android:layout_width="@dimen/activity_main_button_width"
                                android:layout_height="@dimen/activity_main_button_height"
                                android:layout_margin="4dp"
                                android:background="@drawable/contest"
                                android:gravity="center"

                                android:typeface="sans" />


                        </LinearLayout>
                    </io.codetail.widget.RevealFrameLayout>
                </LinearLayout>
            </ScrollView>

            <LinearLayout
                android:id="@+id/ad"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                android:gravity="center"
                android:orientation="horizontal">

                <com.google.android.gms.ads.AdView
                    android:id="@+id/adView"
                    android:layout_width="wrap_content"
                    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>
            </LinearLayout>
        </LinearLayout>

        <fragment
            android:id="@+id/fragment_navigation_drawer"
            android:name="com.smartedutech.ccc.fragment.NavigationFragment"
            android:layout_width="@dimen/fragment_navigation_drawer_width"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            app:layout="@layout/fragment_navigation_drawer"
            tools:layout="@layout/fragment_navigation_drawer" />

    </android.support.v4.widget.DrawerLayout>
</LinearLayout>

Thanks


Solution

  • The align_XXX properties are only applicable in a RelativeLayout. LinearLayouts only lay things out linearly.