RelativeLayout inside Scrollview in android - java

I am stuck in a problem and not able find any solution. This problem may sound very naive but I am really unable to figure out the exact cause. I have a ScrollView ans inside that I have a RelativeLayout. But my RelativeLayout is not scrolling irrespective of the content. I have followed https://stackoverflow.com/relativelayout-with-scrollview-not-scrolling and https://stackoverflow.com/relativelayout-inside-scrollview-not-working and few more also. Please check where I am doing wrong. Thanks.
xml code :
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".MainActivity"
android:scrollbars="vertical"
android:background="#drawable/cover_image"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/cover_img_labels"
android:layout_width="300dp"
android:layout_height="105dp"
android:background="#drawable/cover_image_labels"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
<RelativeLayout
android:id="#+id/rl_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:layout_below="#+id/cover_img_labels"
android:layout_centerHorizontal="true">
<EditText
android:id="#+id/et_login_userName"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:background="#drawable/edittext_style"
android:textColor="#7593B0"
android:singleLine="true"
android:paddingLeft="10dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:hint="#string/hint_login_user" />
<EditText
android:id="#+id/et_login_password"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/et_login_userName"
android:textColor="#7593B0"
android:layout_marginTop="10dp"
android:paddingLeft="10dp"
android:background="#drawable/edittext_style"
android:singleLine="true"
android:hint="#string/hint_login_password"
android:imeOptions="actionDone"
android:inputType="textPassword" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="100dp"
android:orientation="horizontal"
android:id="#+id/linearLayout">
<Button
android:id="#+id/bt_login_submit"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="#string/text_login_submit"
android:layout_marginRight="2dp"
android:textColor="#android:color/white"
android:background="#drawable/button_drawable"
android:layout_below="#+id/et_login_password" />
<Button
android:id="#+id/bt_register_submit"
android:layout_width="0dp"
android:layout_weight="1"
android:background="#drawable/button_drawable"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:textColor="#android:color/white"
android:text="Register your card" />
</LinearLayout>
<ProgressBar
android:id="#+id/pb_login_progressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:visibility="gone" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Forgot Password"
android:id="#+id/bt_forgot_password"
android:textColor="#color/pink"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/forgot_button_drawable"
android:layout_below="#+id/linearLayout"
android:layout_centerHorizontal="true" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_below="#+id/bt_forgot_password"
android:gravity="center"
android:id="#+id/lll"
android:layout_height="match_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/button"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/button2"
android:layout_alignRight="#+id/button"
android:layout_alignEnd="#+id/button" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</ScrollView>

I just run your code, it cannot scroll because height of relative layout not enough. You only scroll when height of ScrollView smaller than height of ScrollView's child.
You can change RelativeLayout's height from wrap_content to 1000dp to test scroll.

Related

App crashes when </ScrollView> put at end

full file follows: trying to have full scroll vertical in android device but putting scroll view at end of file produces crash
`<?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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.cancunsteve.aboutcancunsteve.MainActivity"
tools:showIn="#layout/activity_main">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/scrollView"
android:layout_alignParentStart="true"
android:layout_marginTop="56dp" />
<ImageView android:id="#+id/imageView"
android:layout_column="1"
android:background="#mipmap/lpussy"
android:contentDescription='android:ContentDescription="#string/desc"'
tools:ignore="HardcodedText"
android:layout_width="200dp"
android:layout_height="230dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="serving good people with special deals. "
android:id="#+id/text1"
android:layout_alignTop="#+id/imageView"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:background="#ffffff"
android:foreground="#05ffffff"
android:foregroundTint="#03ffffff"
android:textColor="#000000" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText2"
android:text="Cancun, Playa del Carmen, Chichen Itza."
android:layout_below="#+id/text1"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:text="Holbox, Taxco, Palenque, Acapulco, Guanajuato,
Monterrey, Tenacatita, Mascota"
android:layout_below="#+id/editText2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageButton"
android:layout_below="#+id/editText3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#mipmap/campa"
tools:ignore="ContentDescription"
android:layout_alignBottom="#+id/editText5" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="#+id/editText3"
android:text="thewebmaster#cancunsteve.com"
android:layout_below="#+id/editText"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="#+id/editText"
android:layout_alignEnd="#+id/editText" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/editText4"
android:text=" 011 52 998 8873919"
android:layout_below="#+id/editText3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="42dp"
android:layout_marginStart="32dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText5"
android:text="be sure to visit us for discounts on your hotel bookings"
android:layout_below="#+id/editText4"
android:layout_toRightOf="#+id/scrollView"
android:layout_toEndOf="#+id/scrollView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="click buttons multiple times to change state"
android:id="#+id/textView2"
android:layout_below="#+id/imageButton" />
</RelativeLayout>`
when ScrollView added after Relative layout file won't open put it in brackets proceeded with backslash /
perhaps something I put in between the first and last ScrollView?
I noticed in the examples you show, scrollview appears in the beginning.
I reproduced your activity and after I removed the 2 backgrounds:
android:background="#mipmap/lpussy"
android:background="#mipmap/campa"
the activity does open fine.
Of course the scrollview is useless the way you use it, it must contain 1 container layout and inside that container all the views that you want to scroll.
Remove the backgrounds as well and try again. Maybe the problem is there.
<ScrollView xmlns: android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
your views
</LinearLayout>
</ScrollView>
as scroll view can only contain a sinle child , so wrapping your views in a layout will work
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.cancunsteve.aboutcancunsteve.MainActivity"
tools:showIn="#layout/activity_main">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="56dp" >
<ImageView android:id="#+id/imageView"
android:layout_column="1"
android:background="#mipmap/lpussy"
android:contentDescription='android:ContentDescription="#string/desc"'
tools:ignore="HardcodedText"
android:layout_width="200dp"
android:layout_height="230dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="serving good people with special deals. "
android:id="#+id/text1"
android:layout_alignTop="#+id/imageView"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:background="#ffffff"
android:foreground="#05ffffff"
android:foregroundTint="#03ffffff"
android:textColor="#000000" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText2"
android:text="Cancun, Playa del Carmen, Chichen Itza."
android:layout_below="#+id/text1"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:text="Holbox, Taxco, Palenque, Acapulco, Guanajuato,
Monterrey, Tenacatita, Mascota"
android:layout_below="#+id/editText2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageButton"
android:layout_below="#+id/editText3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#mipmap/campa"
tools:ignore="ContentDescription"
android:layout_alignBottom="#+id/editText5" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="#+id/editText3"
android:text="thewebmaster#cancunsteve.com"
android:layout_below="#+id/editText"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="#+id/editText"
android:layout_alignEnd="#+id/editText" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/editText4"
android:text=" 011 52 998 8873919"
android:layout_below="#+id/editText3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="42dp"
android:layout_marginStart="32dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText5"
android:text="be sure to visit us for discounts on your hotel bookings"
android:layout_below="#+id/editText4"
android:layout_toRightOf="#+id/scrollView"
android:layout_toEndOf="#+id/scrollView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="click buttons multiple times to change state"
android:id="#+id/textView2"
android:layout_below="#+id/imageButton" />
</RelativeLayout>
</ScrollView>
ScrollView must have a single child.
If you want your full layout to be scrollable then add at the top.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background_grey"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/imageView"
android:background="#ffffff"
android:foreground="#05ffffff"
android:foregroundTint="#03ffffff"
android:text="serving good people with special deals. "
android:textColor="#000000" />
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/text1"
android:text="Cancun, Playa del Carmen, Chichen Itza." />
<EditText
android:id="#+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/editText2"
android:text="Holbox, Taxco, Palenque, Acapulco, Guanajuato,
Monterrey, Tenacatita, Mascota" />
<ImageButton
android:id="#+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/editText5"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/editText3"
android:background="#mipmap/ic_launcher"
tools:ignore="ContentDescription" />
<EditText
android:id="#+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/editText"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="#+id/editText"
android:layout_below="#+id/editText"
android:ems="10"
android:inputType="textEmailAddress"
android:text="thewebmaster#cancunsteve.com" />
<EditText
android:id="#+id/editText4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/editText3"
android:layout_marginLeft="42dp"
android:layout_marginStart="32dp"
android:ems="10"
android:inputType="phone"
android:text=" 011 52 998 8873919" />
<EditText
android:id="#+id/editText5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/editText4"
android:layout_toEndOf="#+id/scrollView"
android:layout_toRightOf="#+id/scrollView"
android:text="be sure to visit us for discounts on your hotel bookings" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageButton"
android:text="click buttons multiple times to change state" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
To make RelativeLayout scrollable, put it inside LinearLayout and
then put that LinearLayout inside ScrollView. This will solve the
problem.
Use the format shown below.
<ScrollView xmlns: android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
...
...
...
</RelativeLayout>
</LinearLayout>
</ScrollView>
UPDATE:
Step 1:
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/scrollView"
android:layout_alignParentStart="true"
android:layout_marginTop="56dp"> <---- LOOK HERE (remove /)
Step 2:
</ScrollView> <---- LOOK HERE (end the ScrollView before RelativeLayout)
</RelativeLayout>
As per your xml,
Its better to swap the top two element tags in your xml file.
So that yor RelativeLayout will become a child of ScrollView. and You dont have to edit your remaining layout elements
The result will be..
< ScrollView
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:id="#+id/scrollView"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.cancunsteve.aboutcancunsteve.MainActivity"
tools:showIn="#layout/activity_main">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginTop="56dp" >
And it should end like..
</RelativeLayout>
</ScrollView>
Addition:
You can replace the Relative Layout with a LinearLayout to get Rid of scrollView Errors...
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/scrollView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:orientation="vertical"
android:layout_marginTop="56dp" >
<ImageView android:id="#+id/imageView"
android:layout_column="1"
android:background="#ff0f"
android:contentDescription='android:ContentDescription="#string/desc"'
tools:ignore="HardcodedText"
android:layout_width="200dp"
android:layout_height="230dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="serving good people with special deals. "
android:id="#+id/text1"
android:layout_alignTop="#+id/imageView"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:background="#ffffff"
android:foreground="#05ffffff"
android:foregroundTint="#03ffffff"
android:textColor="#000000" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText2"
android:text="Cancun, Playa del Carmen, Chichen Itza."
android:layout_below="#+id/text1"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:text="Holbox, Taxco, Palenque, Acapulco, Guanajuato,
Monterrey, Tenacatita, Mascota"
android:layout_below="#+id/editText2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageButton"
android:layout_below="#+id/editText3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#f0f0"
tools:ignore="ContentDescription"
android:layout_alignBottom="#+id/editText5" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="#+id/editText3"
android:text="thewebmaster#cancunsteve.com"
android:layout_below="#+id/editText"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="#+id/editText"
android:layout_alignEnd="#+id/editText" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/editText4"
android:text=" 011 52 998 8873919"
android:layout_below="#+id/editText3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="42dp"
android:layout_marginStart="32dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/editText5"
android:text="be sure to visit us for discounts on your hotel bookings"
android:layout_below="#+id/editText4" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="click buttons multiple times to change state"
android:id="#+id/textView2"
android:layout_below="#+id/imageButton" />
</LinearLayout>
</ScrollView>

how to center crop a background image of linear layout?

Hi i had to make a layout with card with recyclerview so for that i set an image as a background to linear layout but now i'm unable to center crop that image
My problem is that i cannot use imageview because using that the height of card increases as well and i don't want that so please if someone can assit me..
my xml
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/primary_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="19dp"
android:layout_marginRight="19dp"
android:layout_marginTop="15dp"
app:cardCornerRadius="115dp">
<ImageView
android:id="#+id/background_image_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:visibility="gone" />
<LinearLayout
android:id="#+id/background_image"
android:layout_width="match_parent"
android:layout_height="210dp"
android:background="#drawable/club1"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profile_image"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:src="#drawable/ellipse" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/first_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:padding="5dp"
android:text="John Doe"
android:textColor="#color/White"
android:textSize="15sp" />
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/second_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:padding="5dp"
android:text="checked in to"
android:textColor="#color/White"
android:textSize="10sp" />
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/third_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:padding="5dp"
android:text="W south"
android:textColor="#color/White"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="horizontal">
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/fourth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="9dp"
android:text="beach mumbai"
android:textColor="#color/White"
android:textSize="15sp" />
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/fifth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/second_text"
android:layout_toRightOf="#+id/fourth_text"
android:text="30 mins ago."
android:textColor="#color/White"
android:textSize="10sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="85dp">
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/sixth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerInParent="true"
android:padding="10dp"
android:text="reply to abc............"
android:textColor="#color/White" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerInParent="true">
<ImageView
android:id="#+id/favourite_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="#drawable/ic_favorite_border_black_24dp" />
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/seventh_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:text="40 likes"
android:textColor="#color/White" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
You can't center crop a background image of linear layout,
But you can achieve the same using these changes:
Replace you LinearLayout with RelativeLayout
Place a ImageView as a first child inside relative layout and use property for center crop.
<RelativeLayout
android:id="#+id/background_image"
android:layout_width="match_parent"
android:layout_height="210dp"
android:orientation="vertical">
<ImageView
android:scaleType="centerCrop"
android:src="#drawable/club1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
.....
......
</RelativeLayout>
If you Want to control The Image View Scale
you need to put it in ImageView As Src Not Background
You can use Frame layout To Achieve it
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/primary_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="19dp"
android:layout_marginRight="19dp"
android:layout_marginTop="15dp"
app:cardCornerRadius="115dp">
<ImageView
android:id="#+id/background_image_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:visibility="gone" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="210dp">
<ImageView
android:layout_width="match_parent"
android:src="#mipmap/ic_launcher"
android:layout_height="match_parent" />
<LinearLayout
android:id="#+id/background_image"
android:layout_width="match_parent"
android:layout_height="210dp"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/profile_image"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:src="#drawable/playstore_icon" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:id="#+id/first_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:padding="5dp"
android:text="John Doe"
android:textSize="15sp" />
<TextView
android:id="#+id/second_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:padding="5dp"
android:text="checked in to"
android:textSize="10sp" />
<TextView
android:id="#+id/third_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:padding="5dp"
android:text="W south"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="horizontal">
<TextView
android:id="#+id/fourth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="9dp"
android:text="beach mumbai"
android:textSize="15sp" />
<TextView
android:id="#+id/fifth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/second_text"
android:layout_toRightOf="#+id/fourth_text"
android:text="30 mins ago."
android:textSize="10sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="85dp">
<TextView
android:id="#+id/sixth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerInParent="true"
android:padding="10dp"
android:text="reply to abc............"
android:textColor="#color/white" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerInParent="true">
<ImageView
android:id="#+id/favourite_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="#drawable/ic_close" />
<TextView
android:id="#+id/seventh_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:text="40 likes"
android:textColor="#color/white" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</FrameLayout>
</android.support.v7.widget.CardView>
CenterCrop logic is baked inside ImageView. The correct solution is to extract it into a Drawable which wraps another Drawable and centerCrops it.
If you use CoordinatorLayout, then just to put your ImageView with centerCrop parameter to top.
<CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:scaleType="centerCrop"
android:background="#drawable/background_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="0dp">
<include layout="#layout/header_main" />
<TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabIndicatorColor="#android:color/white"
android:background="#drawable/white_border_background"
app:tabIndicatorHeight="3dp"/>
</AppBarLayout>
<ViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</CoordinatorLayout>

Unable to set Admob Banner in Bottom

I am trying to set my admob banner on bottom of the screen but it's not showing. I have tried all possible way to set it as bottom but I am unable to set it...its going down side of expandable list view.
My XML is like below...let me know if someone can help me to sort out issue.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#e7e7e7"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1">
<include
layout="#layout/top_points_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/five">
</View>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:layout_width="#dimen/laytop_imgwidthheight"
android:layout_height="#dimen/laytop_imgwidthheight"
android:contentDescription="#string/app_name"
android:src="#drawable/app_icon"
android:visibility="gone" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:gravity="left"
android:padding="#dimen/five"
android:text="Country of Purchase"
android:textColor="#color/Gray"
android:textSize="18sp"
android:textStyle="bold" />
<RelativeLayout
android:id="#+id/layout_country_selection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="5dp"
android:background="#drawable/list_item_background"
android:orientation="horizontal"
android:padding="6dp">
<com.commonutility.RoundImageView
android:id="#+id/imageView_country_logo"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center_vertical"
android:layout_marginBottom="4dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="#drawable/country_default_logo"
android:visibility="visible" />
<TextView
android:id="#+id/textView_country_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:layout_toRightOf="#+id/imageView_country_logo"
android:padding="5dp"
android:text="Select Your Country"
android:textColor="#color/Blue"
android:textSize="19sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginRight="5dp"
android:padding="3dp"
android:src="#drawable/dropdown" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone"
android:weightSum="2">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="#dimen/five"
android:layout_weight="1"
android:gravity="right"
android:paddingBottom="#dimen/five"
android:paddingTop="#dimen/five"
android:text="Country"
android:textColor="#fe4080"
android:textSize="#dimen/rewards_countrytextsize"
android:textStyle="bold" />
<TextView
android:id="#+id/txtcountry"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="left"
android:paddingBottom="#dimen/five"
android:paddingTop="#dimen/five"
android:text="USA"
android:textColor="#color/material_color_primary_dark"
android:textSize="#dimen/rewards_countrytextsize"
android:textStyle="bold" />
</LinearLayout>
<ExpandableListView
android:id="#+id/lvExp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:background="#drawable/list_item_background"
android:cacheColorHint="#android:color/transparent"
android:divider="#color/md_white_1000"
android:dividerHeight="0dp"
android:groupIndicator="#null"
android:scrollbars="none" />
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:clickable="false"
android:nestedScrollingEnabled="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="#string/banner_home_footer">
</com.google.android.gms.ads.AdView>
</LinearLayout>
Let me know what is wrong in this.
Thanks :)
android:layout_alignParentBottom="true"
works only in RelativeLayout, but it's inside a LinearLayout.
You could change the root layout to RelativeLayout and wrap everything but your AdView inside another LinearLayout (or better handle the behaviour of the other views as expected inside a RelativeLayout to avoid deep layouts).

Evenly spacing buttons android

I'm currently working on an android application. I can't get buttons evenly spaced on a screen.
Below is my code.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main_menu"
android:background="#354739"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.cssdapp.MainMenuActivity">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon"
/>
<Button
android:text="Log Off"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#6b5847"
android:id="#+id/logOff"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:text="Manage Farmers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#6b5847"
android:id="#+id/button4"
android:layout_above="#+id/button5"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:text="My Account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#6b5847"
android:id="#+id/button5"
android:layout_marginBottom="47dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:text="Manage Farmers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#6b5847"
android:id="#+id/button3"
android:layout_above="#+id/button4"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="21dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:text="Order History"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#6b5847"
android:id="#+id/button2"
android:layout_above="#+id/button3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:text="Make an Order"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#6b5847"
android:id="#+id/makeOrder"
android:layout_above="#+id/button2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="36dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
I want the buttons evenly spaced down the screen below the image. At the minute the image is where I want to be however I can't get the buttons to where I want them to be. I'm trying to use the gui designer however they won't snap into place. I'm trying to figure out the code way to do it.
Any help appreciated.
In Order to divide the buttons on the whole screen evenly and to maintain synchronization on all devices you need to use a LinearLayout
as your parent View And and another LinearLayout as the parent for each button and apply to it the weight attribute to divide them evenly on the screen Cause you can't just apply the weight attribute on the button itself because the (height or width of it depends on if the layout orintation is horizontal or vertical will gets scaled to fill the whole space) here is a code snippet to demonstrate what am saying
`
<LinearLayout 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:id="#+id/activity_main_menu"
android:layout_marginBottom="#dimen/activity_vertical_margin"
android:layout_marginLeft="#dimen/activity_horizontal_margin"
android:layout_marginRight="#dimen/activity_horizontal_margin"
android:layout_marginTop="#dimen/activity_vertical_margin"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center">
<Button
android:id="#+id/logOff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Log Off"
android:textAllCaps="false"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/button4"
android:text="Manage Farmers"
android:textStyle="bold"
android:textAllCaps="false"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center">
<Button
android:text="My Account"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/button5"
android:textAllCaps="false"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center">
<Button
android:text="Order History"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/button2"
android:textAllCaps="false"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center">
<Button
android:text="Make an Order"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/makeOrder"
android:textAllCaps="false"
android:textStyle="bold"/>
</LinearLayout>
</LinearLayout>`
I have done some changes, Please check if it works for you
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#354739"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<ImageView
android:id="#+id/iv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="23dp"
android:src="#drawable/ic_android_black_24dp"/>
<Button
android:id="#+id/logOff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/iv"
android:layout_marginTop="23dp"
android:background="#6b5847"
android:text="Log Off"/>
<Button
android:id="#+id/button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/button5"
android:layout_marginTop="23dp"
android:background="#6b5847"
android:text="Manage Farmers"/>
<Button
android:id="#+id/button4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/logOff"
android:layout_marginTop="23dp"
android:background="#6b5847"
android:text="Manage Farmers"/>
<Button
android:id="#+id/button5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/button4"
android:layout_marginTop="23dp"
android:background="#6b5847"
android:text="My Account"/>
<Button
android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/button5"
android:layout_marginTop="23dp"
android:background="#6b5847"
android:text="Order History"/>
<Button
android:id="#+id/makeOrder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/button2"
android:layout_marginTop="23dp"
android:background="#6b5847"
android:text="Make an Order"/>
</RelativeLayout>

Relative RecyclerView Scrolling

I have an image and some text and below that i have a sliding tab layout with a view pager and the view pager has 3 fragments each having one recycler view each . Now my problem is that i want to scroll the recyclerview and at the same time i want to scroll the rest of the elements too. For eg when i scroll the recycler view i want all other views to scroll as well. This my XML layout
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:fillViewport="true"
>
<RelativeLayout
android:layout_width="match_parent" android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/imageView7"
android:src="#drawable/aal"
android:adjustViewBounds="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#98000000"
android:id="#+id/innerColor"
android:layout_alignBottom="#+id/imageView7"
android:layout_alignParentTop="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/include"
android:padding="13dp"
>
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:clickable="true"
android:background="#drawable/custom_bg"
android:onClick="BackPressed"
android:src="#drawable/ic_arrow_back"
android:id="#+id/imageView2" />
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:clickable="true"
android:src="#drawable/add"
android:id="#+id/addAction"
android:onClick="showImage"
android:background="#drawable/custom_bg"
android:tint="#color/icons"
android:layout_alignParentEnd="true" />
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="sample "
android:textSize="22sp"
android:id="#+id/textHeader"
android:textColor="#ffffff"
android:layout_marginLeft="12dp"
android:scaleType="centerCrop"
android:layout_above="#+id/descText"
android:layout_marginBottom="10dp"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:id="#+id/descText"
android:layout_marginLeft="12dp"
android:text="Sampletext"
android:layout_above="#+id/Fbutton"
android:layout_marginBottom="10dp"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="Follow"
android:onClick="followUnfollow"
android:background="#drawable/follow_button_bg"
android:stateListAnimator="#null"
android:textColor="#403e3e"
android:padding="5dp"
android:id="#+id/Fbutton"
android:layout_alignParentBottom="true"
android:layout_marginBottom="150dp"
android:layout_centerHorizontal="true" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/Fbutton"
android:layout_marginTop="-80dp"
android:id="#+id/relativeLayout5"
android:layout_centerHorizontal="true">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/relStatMem"
android:layout_alignTop="#+id/relativeLayout5"
android:layout_toEndOf="#+id/relativeLayout5">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/numImages"
android:text="500"
android:textColor="#ffffff"
android:layout_alignParentBottom="false"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/texts"
android:textSize="12dp"
android:textColor="#ffffff"
android:text="PHOTOS"
android:layout_marginLeft="30dp"
android:layout_below="#+id/numImages"
android:layout_centerHorizontal="true" />
<View
android:layout_width="1dp"
android:layout_height="60dp"
android:background="#ffffff"
android:layout_marginLeft="80dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/relStatFol"
android:layout_alignTop="#+id/relStatMem"
android:layout_toEndOf="#+id/relStatMem">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/numMembers"
android:text="5"
android:textColor="#ffffff"
android:layout_alignParentBottom="false"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textsMembers"
android:textSize="12dp"
android:textColor="#ffffff"
android:text="MEMBERS"
android:layout_marginLeft="30dp"
android:layout_below="#+id/numMembers"
android:layout_centerHorizontal="true" />
<View
android:layout_width="1dp"
android:layout_height="60dp"
android:background="#ffffff"
android:layout_marginLeft="80dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/relStatFols"
android:layout_alignTop="#+id/relStatFol"
android:layout_toEndOf="#+id/relStatFol">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/numFolls"
android:text="1B"
android:textColor="#ffffff"
android:layout_alignParentBottom="false"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textsFol"
android:textSize="12dp"
android:textColor="#ffffff"
android:text="FOLLOWERS"
android:layout_marginLeft="30dp"
android:layout_below="#+id/numFolls"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<!--In addition to the two java files we got from google git , this is what you need for tabs-->
<com.example.skmishra.plates.Library.SlidingTabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_below="#+id/innerColor"
android:layout_height="wrap_content">
<!--For elevation add here-->
</com.example.skmishra.plates.Library.SlidingTabLayout>
<android.support.v4.view.ViewPager android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="#id/tabs"
android:id="#+id/viewPager"
android:fillViewport="false">
</android.support.v4.view.ViewPager>
</RelativeLayout>
</ScrollView>
Google + Does that , i would like to implement something simillar
I believe Google used a Collapsing Toolbar Layout, which will collaps the toolbar on scroll or other events.
You can find more information here.
<android.support.design.widget.AppBarLayout
android:layout_height="192dp"
android:layout_width="match_parent">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
app:layout_collapseMode="pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

Categories