android


How to place sticky ad bottom of the recyclervew?


I have placed ad bottom of the recyclerview but it doesn't appear . When I scroll up then it appears. But I want to keep it sticky. How can I do it? Please help.
Similar this app.
Here is my layout,
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="com.tofabd.internetspeedmeter.ui.fragment.MonthFragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/total_bar"
android:orientation="vertical">
<LinearLayout
android:id="#+id/id_titlebar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:orientation="horizontal"
android:paddingBottom="2dp"
android:paddingTop="3dp"
android:weightSum="13">
<TextView
android:id="#+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:gravity="start"
android:paddingLeft="15dp"
android:text="Date"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:paddingRight="2dp"
android:text="Wifi"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="#+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:paddingRight="2dp"
android:text="Mobile"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="#+id/textView4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:paddingRight="10dp"
android:text="Total"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/cardList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
android:background="#FFFFFF"
android:clipToPadding="false" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/total_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/bottom_ad"
android:layout_alignParentTop="false"
android:background="?attr/colorPrimary"
android:orientation="horizontal"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:weightSum="13">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:gravity="start"
android:paddingLeft="15dp"
android:text="Total"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="#+id/id_wifi"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:paddingRight="2dp"
android:text="Wifi"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="#+id/id_mobile"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:paddingRight="2dp"
android:text="Mobile"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="#+id/id_total"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:paddingRight="10dp"
android:text="Total"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/bottom_ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="#string/banner_home">
</com.google.android.gms.ads.AdView>
</LinearLayout>
</RelativeLayout>
</FrameLayout>
Here is output, I want to keep the ad stikcy.
If you are using CoordinatorLayout, Try adding android:fitsSystemWindows= true in CoordinatorLayout!
Try This
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/id_titlebar"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:orientation="horizontal"
android:paddingBottom="2dp"
android:paddingTop="3dp"
android:weightSum="13">
<TextView
android:id="#+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:gravity="start"
android:paddingLeft="15dp"
android:text="Date"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:paddingRight="2dp"
android:text="Wifi"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="#+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:paddingRight="2dp"
android:text="Mobile"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="#+id/textView4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:paddingRight="10dp"
android:text="Total"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_below="#+id/id_titlebar"
android:layout_above="#+id/total_bar">
<android.support.v7.widget.RecyclerView
android:id="#+id/cardList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
android:background="#FFFFFF"
android:clipToPadding="false" />
</LinearLayout>
<LinearLayout
android:id="#+id/total_bar"
android:layout_above="#+id/bottom_ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:orientation="horizontal"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:weightSum="13"
android:gravity="center_vertical">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:gravity="start"
android:paddingLeft="15dp"
android:text="Total"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="#+id/id_wifi"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:paddingRight="2dp"
android:text="Wifi"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="#+id/id_mobile"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:paddingRight="2dp"
android:text="Mobile"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="#+id/id_total"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:paddingRight="10dp"
android:text="Total"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/bottom_ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:gravity="center">
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="#string/banner_home">
</com.google.android.gms.ads.AdView>
</LinearLayout>
</RelativeLayout>
</FrameLayout>
I have edited your .xml try it out
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/id_titlebar"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:orientation="horizontal"
android:paddingBottom="2dp"
android:paddingTop="3dp"
android:weightSum="13">
<TextView
android:id="#+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:gravity="start"
android:paddingLeft="15dp"
android:text="Date"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:paddingRight="2dp"
android:text="Wifi"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="#+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:paddingRight="2dp"
android:text="Mobile"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="#+id/textView4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:paddingRight="10dp"
android:text="Total"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_below="#+id/id_titlebar"
android:layout_above="#+id/total_bar">
<android.support.v7.widget.RecyclerView
android:id="#+id/cardList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
android:background="#FFFFFF"
android:clipToPadding="false" />
</LinearLayout>
<LinearLayout
android:id="#+id/total_bar"
android:layout_above="#+id/bottom_ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:orientation="horizontal"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:weightSum="13"
android:gravity="center_vertical">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:gravity="start"
android:paddingLeft="15dp"
android:text="Total"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="#+id/id_wifi"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:paddingRight="2dp"
android:text="Wifi"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="#+id/id_mobile"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:paddingRight="2dp"
android:text="Mobile"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="#+id/id_total"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:paddingRight="10dp"
android:text="Total"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/bottom_ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:gravity="center">
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="#string/banner_home">
</com.google.android.gms.ads.AdView>
</LinearLayout>
</RelativeLayout>
</FrameLayout>

Related Links

Running task periodicaly(once a day/once a week)
How to set Progress Bar to the Linear layout on click of Gallery Items?
Water effect “on android” for a 2D game. Where to start?
How to clear the previous activity after starting new activity
Rotated OpenStreetMap view - how to Swipe map in direction of finger move after rotation in Android?
back button not working
Nexus S Flash torch mode not working
Change a checkbox state from an alertdialog
android gallery view change alpha value
Trouble with JSON decoding … JSONException : end of input at chatacter 0
Android - adding photos taken by the user into a listview
im not getting TopLeft & Bottom right longitude and lattitude value for my MapView
Substitute of iframe (external dynamic page url open) in respect to Jquerymobile
select a word on a tap in TextView/EditText
setText of TextView in onDraw method of a custom view in android
Arranging Button dynamically in STAR pattern android

Categories

HOME
azure-stream-analytics
paraview
alexa-skills-kit
formal-languages
mjml
angular-formly
interface
pascal
camera
bitbucket-api
spring-data-mongodb
hugo
nested-if
trac
syntaxnet
supervisor
nancy
esoteric-languages
feathersjs
guzzle
gmock
ckfinder
corpus
entity-relationship-model
sinch
uitapgesturerecognizer
boost-asio
autodesk-designautomation
recurring-events
quickfixj
glib
laravel-eloquent
baidu-map
numpy-broadcasting
xajax
watchman
timing
tex
flatmap
projects-and-solutions
laravel-elixir
levenshtein-distance
skylink
attributeerror
branching-and-merging
naming
sharp-snmp
oracle-service-bus
apollostack
avcapturedevice
mesosphere
dynamic-linq
xbmc
openrasta
sonarlint-eclipse
serde
twilio-click-to-call
spring-data-couchbase
dt
objectscript
mathcad
chromium-os
cudd
xcode-server
dup
tooleap
cifilter
vorpal.js
avspeechsynthesizer
embedding
nullable
boomerang
gocql
sql-server-data-tools
apache-commons-daemon
mmwormhole
angular-gettext
boost-program-options
addressing-mode
crowd
formview
nsmenu
insight.database
mutual-authentication
decoupling
hibernate-entitymanager
http-patch
kendo-dataviz
c++builder-xe5
ebay-lms
cmmi
asplinkbutton
vfs
objectquery
apache-whirr
jdb
google-maps-mobile
xcelsius
rmdir
clrstoredprocedure
msr
codebase
nhprof
globals
alsb
flvplayback
soappy
xslcompiledtransform
blind
cardspace

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App