hello AdMob banner ads not showing up any more after I add ScrollView I don't know why I tried many time but nothing
before added ScrollView is was working well
I have tried many methods to put in bottom the layout but not working with me
plz if you can help me I want to I want to place the ad on the bottom I have a LinearLayout. When I do it never shows up
<Toolbar
android:id="#+id/mytoolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</Toolbar>
<ScrollView
android:layout_above="#+id/adView"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:gravity="center_vertical"
android:background="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15.0dip">
<TextView
android:textSize="17.0sp"
android:textColor="#ff000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Extreme power saving mode" />
</LinearLayout>
<Switch
android:id="#+id/setSwitch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10.0dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:gravity="bottom">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="#string/ad_banner">
</com.google.android.gms.ads.AdView>
</LinearLayout>
</LinearLayout>
I looked into your code. Wrap your layout in relative. Layout below and above only works in relative not in linear, and remove the two linear layout below that is wrapping the adView.
This should work
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:orientation="vertical"
android:background="#fff1f1f1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto">
<Toolbar
android:id="#+id/mytoolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</Toolbar>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/mytoolbar"
android:layout_above="#+id/adView">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:gravity="center_vertical"
android:background="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15.0dip">
<TextView
android:textSize="17.0sp"
android:textColor="#ff000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Extreme power saving mode" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3.0dip"
android:text="The disadvantage is that the playback progress will be lost."
android:ems="11" />
</LinearLayout>
<Switch
android:id="#+id/setSwitch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10.0dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
</RelativeLayout>
<RelativeLayout
android:background="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10.0dip">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15.0dip">
<TextView android:textSize="17.0sp"
android:textColor="#ff000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Desktop control playback" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3.0dip"
android:text="Quickly click or swipe three times" />
</LinearLayout>
<Switch android:id="#+id/setSwitch2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10.0dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
</RelativeLayout>
<RelativeLayout
android:background="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10.0dip">
<TextView
android:textSize="17.0sp"
android:textColor="#ff000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15.0dip"
android:text="Sound" />
<Switch
android:id="#+id/setSwitch3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10.0dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/setRelativeLayout1"
android:background="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10.0dip">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15.0dip">
<TextView
android:textSize="17.0sp"
android:textColor="#ff000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Compatibility mode" />
<TextView
android:id="#+id/moreTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3.0dip"
android:text="MIUI8 set as lock screen wallpaper" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/setRelativeLayout2"
android:background="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10.0dip">
<TextView
android:textSize="17.0sp"
android:textColor="#ff000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15.0dip"
android:text="Get Starry Sky Wallpaper" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlRate"
android:background="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10.0dip">
<TextView android:textSize="17.0sp"
android:textColor="#ff000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15.0dip"
android:text="rate us " />
</RelativeLayout>
<RelativeLayout android:id="#+id/setRelativeLayout3"
android:background="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10.0dip">
<TextView android:textSize="17.0sp"
android:textColor="#ff000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15.0dip"
android:text="Close wallpaper" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="#string/ad_banner">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
Related
I have developing android app.
I have problem when displaying list of card in recycler-view that within in fragment_auction_products.xml.
When I navigate to FragmentAuctionProducts, I have the
this is the problem
As you can see my list starts showing after 50% space is empty... How I can solve this?
My fragment_auction_products.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:gravity="top"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/home_auction_products_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:gravity="top"
android:layout_marginTop="10dp"/>
<ProgressBar
android:id="#+id/home_auction_products_loader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminateDrawable="#drawable/spinner_ring"
android:indeterminateOnly="true" />
</LinearLayout>
My recycler view item:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="10dp"
android:gravity="center"
android:background="#drawable/layer_shadow"
android:orientation="horizontal">
<ImageView
android:id="#+id/home_auction_products_recycler_view_image"
android:layout_margin="4dp"
android:layout_width="125dp"
android:layout_height="150dp"
android:src="#drawable/card_example_1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_marginStart="15dp"
android:layout_marginEnd="10dp"
android:orientation="vertical"
android:paddingTop="15dp">
<TextView
android:id="#+id/home_auction_products_recycler_view_title"
style="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/muli_bold"
android:text="Title"
android:textColor="#color/colorBlack"
android:textSize="14dp" />
<TextView
android:id="#+id/home_auction_products_recycler_view_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/muli_bold"
android:text="id"
android:textColor="#color/colorBlack"
android:textSize="0dp" />
<TextView
android:id="#+id/home_auction_products_recycler_view_current_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/muli_bold"
android:text="50000 тг"
android:textColor="#color/colorTextYellow"
android:textSize="16dp" />
<TextView
android:id="#+id/home_auction_products_recycler_view_start_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/muli"
android:text="start-price"
android:textColor="#color/colorBlack"
android:textSize="12dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="8dp"
android:background="#drawable/auction_products_shape"
android:gravity="center"
android:orientation="vertical"
android:paddingLeft="4dp"
android:paddingTop="2dp"
android:paddingRight="4dp"
android:paddingBottom="2dp">
<TextView
android:id="#+id/home_auction_products_recycler_view_day"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="#font/muli"
android:gravity="center"
android:text="10"
android:textColor="#color/colorWhite"
android:textSize="14dp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="#font/muli"
android:gravity="center"
android:text="ДНЕЙ"
android:textColor="#color/colorWhite"
android:textSize="6dp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/auction_products_shape"
android:gravity="center"
android:orientation="vertical"
android:paddingLeft="4dp"
android:paddingTop="2dp"
android:paddingRight="4dp"
android:paddingBottom="2dp">
<TextView
android:id="#+id/home_auction_products_recycler_view_hour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="#font/muli"
android:gravity="center"
android:text="12"
android:textColor="#color/colorWhite"
android:textSize="14dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="#font/muli"
android:gravity="center"
android:text="ЧАСОВ"
android:textColor="#color/colorWhite"
android:textSize="6dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:orientation="horizontal">
<TextView
android:id="#+id/home_auction_products_recycler_view_show"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_mdi_keyboard_arrow_right"
android:fontFamily="#font/muli"
android:textColor="#color/colorTextGray"
android:textSize="12dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
My main container where I call my fragments:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/colorWhite"
tools:context=".activity.MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/bottom_nav_bar">
<FrameLayout
android:id="#+id/main_fragment_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</ScrollView>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottom_nav_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="?android:windowBackground"
app:menu="#menu/menu" />
</RelativeLayout>
Change the FrameLayout height to match_parent.
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/bottom_nav_bar">
<FrameLayout
android:id="#+id/main_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</ScrollView>
Just use android:layout_alignParentTop.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/home_auction_products_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:gravity="top"
android:layout_marginTop="10dp"/>
<ProgressBar
android:id="#+id/home_auction_products_loader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminateDrawable="#drawable/spinner_ring"
android:indeterminateOnly="true" />
</LinearLayout>
Hope this helps.
I'm developing an Android app.
As you can see in the attached screenshot, I have an ImageView in a small size. I load it by Picasso library. Now, I'd like to enlarge it by onClick event in a new ImageView more large (id: enlarge_image, in .XML) . I looked for a solution everywhere, also throught the Android site's guide, but I don't know how to do implement it. Can anyone help me? Thanks.
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:andorid="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/viewA"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.65"
android:orientation="horizontal">
<ImageView
android:id="#+id/img_poster_film"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:scaleType="centerCrop"
app:srcCompat="#drawable/ic_star_rate_black_18dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/viewB"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:orientation="vertical"
android:padding="8dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp">
<TextView
android:id="#+id/index_title"
style="#style/reference_index"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/title_film" />
<TextView
android:id="#+id/original_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#color/title_color"
android:textSize="20dp" />
</LinearLayout>
<View style="#style/separator" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp">
<TextView
style="#style/reference_index"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/genres_film" />
<TextView
android:id="#+id/genres_film"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingTop="8dp">
<TextView
style="#style/reference_index"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/date_release_film" />
<TextView
android:id="#+id/date_release_film"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"/>
<TextView
style="#style/reference_index"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="35dp"
android:layout_marginStart="35dp"
android:text="#string/duration_film" />
<TextView
android:id="#+id/duration_film"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp" />
</LinearLayout>
<View style="#style/separator" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="10dp">
<TextView
style="#style/reference_index"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/overview_film" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/overview_film"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="15sp"
android:layout_marginTop="5dp"
android:textStyle="italic" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:backgroundTint="#color/light_azure"
android:clickable="true"
android:src="#drawable/ic_star_rate_black_18dp"
app:layout_anchor="#id/viewA"
app:layout_anchorGravity="bottom|right|end" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp">
<ImageView
android:id="#+id/enlarged_image"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
I have a layout, in which I need that the top header should should not hide when I open softKeyBoard. I am using Fragment here.I am using recylerView.
when i am opening softkeyboard the top header is scrolling up. I need that header to stay there and Recyclerview to scroll.
Below is my xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/rel_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bggradient">
<RelativeLayout
android:id="#+id/rel_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="#drawable/drawable_below_line">
<ImageView
android:id="#+id/iv_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/txtSettingHeader"
android:layout_alignTop="#+id/txtSettingHeader"
android:layout_centerVertical="true"
android:background="#drawable/button_selector"
android:onClick="onClickEvent"
android:padding="10dp"
android:src="#mipmap/ic_back" />
<TextView
android:id="#+id/txtUserName"
style="#style/FragHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" />
<ImageView
android:id="#+id/iv_userImage"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/txtUserName"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/txtUserName"
android:layout_centerVertical="true"
android:onClick="onViewClick"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:src="#mipmap/ic_male" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/lin_comment"
android:layout_below="#+id/rel_header"
android:gravity="top"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/RecyelerViewChat"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
</android.support.v7.widget.RecyclerView>
<TextView
android:id="#+id/tv_txtNoRecords"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:minHeight="100dp"
android:text="#string/txtNoChat"
android:textColor="#android:color/white"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="#+id/lin_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#70FFFFFF"
android:gravity="center"
android:orientation="horizontal"
android:padding="5dp">
<LinearLayout
android:id="#+id/linEditComment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusableInTouchMode="true"
android:orientation="horizontal">
<ImageView
android:id="#+id/iv_imgToggleKeyboardEmoji"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:src="#mipmap/ic_emoji" />
<com.lawo.emojicon.EmojiconEditText
android:id="#+id/et_edtChat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/drawable_black_border"
android:hint="#string/hintTypeMessage"
android:inputType="textNoSuggestions|textMultiLine"
android:maxLength="500"
android:maxLines="3"
android:padding="10dp"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray" />
</LinearLayout>
<ImageView
android:id="#+id/iv_imgSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:onClick="onClickEvent"
android:padding="10dp"
android:src="#mipmap/ic_sent" />
</LinearLayout>
</RelativeLayout>
Add the following to your "activity" tag in AndroidManifest.xml:
android:windowSoftInputMode="adjustResize"
Reference: Specify How Your UI Should Respond.
My marking has some elements. These elements shall be scrolled completely, when scrolling down the calendar shall leave for screen limits if it it is necessary and to scroll LinearLayout contents.
I already tried to add ScrollView, it was ineffectual since all screen entirely but only a calendar, I ask to help was scrolled not.
Here Layout code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LinearLayout_calendar"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:scrollbars="vertical" >
<RelativeLayout
android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/calendar_top" >
<RelativeLayout
android:id="#+id/previous"
android:layout_width="40dip"
android:layout_height="30dip"
android:layout_alignParentLeft="true" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/arrow_left" />
</RelativeLayout>
<TextView
android:id="#+id/title_calendar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dip"
android:textColor="#000000"
android:textSize="18dip"
android:textStyle="bold" />
<RelativeLayout
android:id="#+id/next"
android:layout_width="40dip"
android:layout_height="30dip"
android:layout_alignParentRight="true" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/arrow_right" />
</RelativeLayout>
</RelativeLayout>
<GridView
android:id="#+id/gridview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:listSelector="#android:color/transparent"
android:numColumns="7"
android:stretchMode="columnWidth" >
</GridView>
<LinearLayout
android:id="#+id/linLayout_all_ivents_in_this_day"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:scrollbars="vertical" >
</LinearLayout>
</LinearLayout>
You can use scrollView.
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
-> your xml code <-
</ScrollView>
The only think you need to know is that scrollview only can have one child node, preferencialy a LinearLayout.
Use the ScrollView: http://developer.android.com/reference/android/widget/ScrollView.html
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="#+id/LinearLayout_calendar"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:scrollbars="vertical" >
<RelativeLayout
android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/calendar_top" >
<RelativeLayout
android:id="#+id/previous"
android:layout_width="40dip"
android:layout_height="30dip"
android:layout_alignParentLeft="true" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/arrow_left" />
</RelativeLayout>
<TextView
android:id="#+id/title_calendar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dip"
android:textColor="#000000"
android:textSize="18dip"
android:textStyle="bold" />
<RelativeLayout
android:id="#+id/next"
android:layout_width="40dip"
android:layout_height="30dip"
android:layout_alignParentRight="true" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/arrow_right" />
</RelativeLayout>
</RelativeLayout>
<GridView
android:id="#+id/gridview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:listSelector="#android:color/transparent"
android:numColumns="7"
android:stretchMode="columnWidth" >
</GridView>
<LinearLayout
android:id="#+id/linLayout_all_ivents_in_this_day"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:scrollbars="vertical" >
</LinearLayout>
</LinearLayout>
</ScrollView>
Ive got this project and ive put admob on it but the ad must always be on the bottom of the screen and when you scroll up and down the page the ad must stay in the same place.
It seems ive done something wrong somewhere as the ad has its own little scroll view layout? Ive put a screen shot below along with the code for the layout
edited homexml code but with error
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:id="#+id/ScrlView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="20dp"
android:layout_weight="1">
<ScrollView
android:id="#+id/ScrlView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/MainActivity"
android:layout_marginBottom="20dp" >
<LinearLayout
android:id="#+id/layoutForScroll"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="vertical" >
<TextView
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="23dp"
android:gravity="center"
android:text="Welcome To Ride Count!"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#1E90FF"
android:textStyle="bold" >
</TextView>
<RelativeLayout
android:id="#+id/layoutTextViews_one"
android:layout_width="280dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:background="#drawable/smallbox1" >
<TextView
android:id="#+id/txtCountLabel_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="24dp"
android:gravity="center"
android:text="Rides Ridden:"
android:textColor="#1E90FF"
android:textStyle="bold" >
</TextView>
<TextView android:textStyle="bold" android:gravity="center" android:text="0000" android:layout_height="wrap_content"
android:layout_width="match_parent" android:id="#+id/sum"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000" android:layout_marginTop="45dp"></TextView>
</RelativeLayout>
<TextView
android:id="#+id/txtFact"
android:layout_width="280dp"
android:layout_height="180dp"
android:layout_gravity="center"
android:layout_marginTop="23dp"
android:background="#drawable/factbox"
android:gravity="center"
android:text="Tap For Fact"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000"
android:textStyle="bold" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/MainActivity"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="0dp"
android:layout_weight="2">
</LinearLayout>
<com.google.ads.AdView
xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
googleads:adSize="SMART_BANNER"
googleads:adUnitId="#string/admob_id" />
</LinearLayout>
ad mob layout code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ad_catalog_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/banner_bottom" />
<TextView android:id="#+id/status"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:text="" />
<com.google.ads.AdView
xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/ad"
android:layout_width="fill_parent"
android:layout_height="60dp"
googleads:adSize="IAB_MRECT"
googleads:adUnitId="#string/admob_id" />
</LinearLayout>
home XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/backgroundtowers"
android:orientation="vertical"
android:scrollbars="vertical"
android:weightSum="1" >
<ScrollView
android:id="#+id/ScrlView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/MainActivity"
android:layout_marginBottom="20dp" >
<LinearLayout
android:id="#+id/layoutForScroll"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="vertical" >
<TextView
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="23dp"
android:gravity="center"
android:text="Welcome To Ride Count"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#1E90FF"
android:textStyle="bold" >
</TextView>
<RelativeLayout
android:id="#+id/layoutTextViews_one"
android:layout_width="280dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:background="#drawable/smallbox1" >
<TextView
android:id="#+id/txtCountLabel_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="24dp"
android:gravity="center"
android:text="Rides Ridden:"
android:textColor="#1E90FF"
android:textStyle="bold" >
</TextView>
<TextView
android:id="#+id/sum"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="45dp"
android:gravity="center"
android:text="0000"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000"
android:textStyle="bold" >
</TextView>
</RelativeLayout>
<TextView
android:id="#+id/txtFact"
android:layout_width="280dp"
android:layout_height="180dp"
android:layout_gravity="center"
android:layout_marginTop="23dp"
android:background="#drawable/factbox"
android:gravity="center"
android:text="Tap For Fact"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000"
android:textStyle="bold" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/MainActivity"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_marginTop="0dp" >
</LinearLayout>
</RelativeLayout>
Change the layout_height and layout_width to wrap_content of your ad to see if that removes it. You may also want to try using the SMART_BANNER option in asSize to adjust for size automatically.
The SMART_BANNER option was added in AdMob version 6.0. Take a look at https://developers.google.com/mobile-ads-sdk/docs/admob/smart-banners. It's way easier to work with.
<com.google.ads.AdView
xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
googleads:adSize="SMART_BANNER"
googleads:adUnitId="#string/admob_id" />
I'd use a LinearLayout since it's a bit easier in this case, but you can still use a RelativeLayout if you prefer them. The idea is to put the AdView in the XML and use layout_weight to the rest of your layout to fill the View.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:id="#+id/ScrlView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="20dp"
android:layout_weight="1">
<!-- ... -->
</ScrollView>
<com.google.ads.AdView
xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
googleads:adSize="SMART_BANNER"
googleads:adUnitId="#string/admob_id" />
</LinearLayout>
ScrollView and your AdView need to be peers in your RelativeLayout. I have implemented exactly what you desire in this way.
RelativeLayout
ScrollView
LinearLayout
AdView