Hi am try to add scroll to my activity.
My activity has two files
1)activity_temple_details
2)content_temple_details
When i try to scroll. The contents are visible on top of the app bar.
like this
I want the contents to go behind the appbar or disapper while scrolling
here is my code
activity_temple_details
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true"
tools:context="baman.lankahomes.lk.jaffnatemples.Temple_Details">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_temple__details" />
</android.support.design.widget.CoordinatorLayout>
content_temple_details
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:layout_centerInParent="true"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="baman.lankahomes.lk.jaffnatemples.Temple_Details"
tools:showIn="#layout/activity_temple__details">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:id="#+id/IV_temple_logo"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#drawable/ic_action_movie"
android:background="#drawable/image_view_style"
android:layout_marginRight="5dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Temple Name"
android:id="#+id/textView"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:layout_marginLeft="8dp"
android:textSize="14dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/TV_title"
android:layout_below="#+id/textView"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:textSize="14dp"
android:layout_marginLeft="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Address"
android:id="#+id/textView3"
android:layout_below="#+id/TV_title"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:layout_marginTop="10dp"
android:layout_marginLeft="8dp"
android:textSize="14dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/TV_address"
android:layout_below="#+id/textView3"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:textSize="14dp"
android:layout_marginLeft="8dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Description"
android:id="#+id/textView5"
android:layout_below="#+id/IV_temple_logo"
android:layout_alignRight="#+id/IV_temple_logo"
android:layout_alignEnd="#+id/IV_temple_logo"
android:layout_marginTop="10dp"
android:textSize="14dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/TV_Description"
android:layout_below="#+id/textView5"
android:layout_alignRight="#+id/TV_title"
android:layout_alignEnd="#+id/TV_title"
android:background="#drawable/textview_style"
android:textSize="14dp"
android:layout_marginTop="8dp"
android:scrollbars = "vertical"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Directions"
android:id="#+id/button"
android:background="#drawable/button_selector"
android:textColor="#android:color/white"
android:textStyle="bold"
android:textSize="18dp"
android:layout_marginTop="70dp"
android:layout_below="#+id/TV_Description"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Search Again"
android:id="#+id/button2"
android:background="#drawable/button_selector"
android:textColor="#android:color/white"
android:textStyle="bold"
android:textSize="18dp"
android:layout_alignTop="#+id/button"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Suggest an Edit"
android:id="#+id/button3"
android:background="#drawable/button_selector"
android:textColor="#android:color/white"
android:textStyle="bold"
android:textSize="18dp"
android:layout_below="#+id/button"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="15dp" />
</RelativeLayout>
</ScrollView>
can some one help me to fix this. tnx.
Try adding following line in scrollview
android:layout_marginTop="?attr/actionBarSize"
I guess it will help, It solved my problem.
layout file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="?attr/actionBarSize"
>
<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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:layout_centerInParent="true"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="baman.lankahomes.lk.jaffnatemples.Temple_Details"
tools:showIn="#layout/activity_temple__details">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:id="#+id/IV_temple_logo"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#drawable/ic_action_movie"
android:background="#drawable/image_view_style"
android:layout_marginRight="5dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Temple Name"
android:id="#+id/textView"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:layout_marginLeft="8dp"
android:textSize="14dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/TV_title"
android:layout_below="#+id/textView"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:textSize="14dp"
android:layout_marginLeft="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Address"
android:id="#+id/textView3"
android:layout_below="#+id/TV_title"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:layout_marginTop="10dp"
android:layout_marginLeft="8dp"
android:textSize="14dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/TV_address"
android:layout_below="#+id/textView3"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:textSize="14dp"
android:layout_marginLeft="8dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Description"
android:id="#+id/textView5"
android:layout_below="#+id/IV_temple_logo"
android:layout_alignRight="#+id/IV_temple_logo"
android:layout_alignEnd="#+id/IV_temple_logo"
android:layout_marginTop="10dp"
android:textSize="14dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/TV_Description"
android:layout_below="#+id/textView5"
android:layout_alignRight="#+id/TV_title"
android:layout_alignEnd="#+id/TV_title"
android:background="#drawable/textview_style"
android:textSize="14dp"
android:layout_marginTop="8dp"
android:scrollbars = "vertical"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Directions"
android:id="#+id/button"
android:background="#drawable/button_selector"
android:textColor="#android:color/white"
android:textStyle="bold"
android:textSize="18dp"
android:layout_marginTop="70dp"
android:layout_below="#+id/TV_Description"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Search Again"
android:id="#+id/button2"
android:background="#drawable/button_selector"
android:textColor="#android:color/white"
android:textStyle="bold"
android:textSize="18dp"
android:layout_alignTop="#+id/button"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Suggest an Edit"
android:id="#+id/button3"
android:background="#drawable/button_selector"
android:textColor="#android:color/white"
android:textStyle="bold"
android:textSize="18dp"
android:layout_below="#+id/button"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="15dp" />
</RelativeLayout>
</ScrollView>
Within the CoordinatorLayout you have to use NestedScrollView but not ScrollView,
here is your solution
content_temple_details.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:layout_centerInParent="true"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="baman.lankahomes.lk.jaffnatemples.Temple_Details"
tools:showIn="#layout/activity_temple__details">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:id="#+id/IV_temple_logo"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#drawable/ic_action_movie"
android:background="#drawable/image_view_style"
android:layout_marginRight="5dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Temple Name"
android:id="#+id/textView"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:layout_marginLeft="8dp"
android:textSize="14dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/TV_title"
android:layout_below="#+id/textView"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:textSize="14dp"
android:layout_marginLeft="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Address"
android:id="#+id/textView3"
android:layout_below="#+id/TV_title"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:layout_marginTop="10dp"
android:layout_marginLeft="8dp"
android:textSize="14dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/TV_address"
android:layout_below="#+id/textView3"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:textSize="14dp"
android:layout_marginLeft="8dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Description"
android:id="#+id/textView5"
android:layout_below="#+id/IV_temple_logo"
android:layout_alignRight="#+id/IV_temple_logo"
android:layout_alignEnd="#+id/IV_temple_logo"
android:layout_marginTop="10dp"
android:textSize="14dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/TV_Description"
android:layout_below="#+id/textView5"
android:layout_alignRight="#+id/TV_title"
android:layout_alignEnd="#+id/TV_title"
android:background="#drawable/textview_style"
android:textSize="14dp"
android:layout_marginTop="8dp"
android:scrollbars = "vertical"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Directions"
android:id="#+id/button"
android:background="#drawable/button_selector"
android:textColor="#android:color/white"
android:textStyle="bold"
android:textSize="18dp"
android:layout_marginTop="70dp"
android:layout_below="#+id/TV_Description"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Search Again"
android:id="#+id/button2"
android:background="#drawable/button_selector"
android:textColor="#android:color/white"
android:textStyle="bold"
android:textSize="18dp"
android:layout_alignTop="#+id/button"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Suggest an Edit"
android:id="#+id/button3"
android:background="#drawable/button_selector"
android:textColor="#android:color/white"
android:textStyle="bold"
android:textSize="18dp"
android:layout_below="#+id/button"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="15dp" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
/*Change it according to your requirement **/
<RelativeLayout
android:id="#+id/relative_activity_main"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#color/mainBackGroundColor"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="#+id/linearlayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="#+id/app_bar_id"
layout="#layout/app_bar"></include>
<include
android:id="#+id/yourlayout_id"
layout="#layout/yourLayout"></include>
</LinearLayout>
</RelativeLayout>
Please set layout behaviour inside your scrollview
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
Related
<?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/colorPrimaryDark"
tools:context="com.example.fake9.tendee.SettingsActivity">
<TextView
android:id="#+id/settings_display_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="119dp"
android:text="Name"
android:textColor="#android:color/white"
android:textSize="30sp" />
<TextView
android:id="#+id/settings_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/settings_display_name"
android:layout_centerHorizontal="true"
android:layout_marginTop="61dp"
android:text="Email"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/settings_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/settings_display_name"
android:layout_below="#+id/settings_email"
android:layout_marginTop="62dp"
android:layout_centerHorizontal="true"
android:text="Decription"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/settings_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/settings_description"
android:layout_centerHorizontal="true"
android:layout_marginTop="80dp"
android:text="Address"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/settings_edit_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignBottom="#+id/settings_description"
android:layout_marginStart="37dp"
android:layout_toEndOf="#+id/settings_description"
android:drawableStart="#drawable/ic_mode_edit_white_18dp" />
<TextView
android:id="#+id/settings_edit_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignBottom="#+id/settings_address"
android:layout_alignStart="#+id/settings_edit_description"
android:drawableStart="#drawable/ic_mode_edit_white_18dp" />
<Button
android:id="#+id/EditPassBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="31dp"
android:backgroundTint="#color/colorAccent"
android:text="Change Password"
android:textColor="#android:color/black" />
</RelativeLayout>
How do I center the text in the TextView in the center? The others are working but not the center one. I have added the same tags I have added for the other textviews. I would like all the text here to be centered.
The pictures to the right of the text are also textviews. I'm not sure what more I can do as all the tags are the same.
Try using this:
<?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/colorPrimaryDark"
tools:context="com.example.fake9.tendee.SettingsActivity">
<TextView
android:id="#+id/settings_display_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:gravity="center"
android:layout_marginTop="119dp"
android:text="Name"
android:textColor="#android:color/white"
android:textSize="30sp" />
<TextView
android:id="#+id/settings_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/settings_display_name"
android:layout_centerHorizontal="true"
android:gravity="center"
android:layout_marginTop="61dp"
android:text="Email"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/settings_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/settings_display_name"
android:layout_below="#+id/settings_email"
android:gravity="center"
android:layout_marginTop="62dp"
android:drawableEnd="#drawable/ic_mode_edit_white_18dp"
android:drawableRight="#drawable/ic_mode_edit_white_18dp"
android:layout_centerHorizontal="true"
android:text="Decription"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/settings_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/settings_description"
android:layout_centerHorizontal="true"
android:layout_marginTop="80dp"
android:gravity="center"
android:drawableEnd="#drawable/ic_mode_edit_white_18dp"
android:drawableRight="#drawable/ic_mode_edit_white_18dp"
android:text="Address"
android:textColor="#android:color/white"
android:textSize="18sp"
/>
<Button
android:id="#+id/EditPassBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="31dp"
android:backgroundTint="#color/colorAccent"
android:text="Change Password"
android:textColor="#android:color/black" />
</RelativeLayout>
Kindly use android:layout_gravity="center_horizontal"
<?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/colorPrimaryDark"
tools:context="com.example.fake9.tendee.SettingsActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="10dp">
<TextView
android:id="#+id/settings_display_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="119dp"
android:text="Name"
android:textColor="#android:color/white"
android:textSize="30sp" />
<TextView
android:id="#+id/settings_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/settings_display_name"
android:layout_centerHorizontal="true"
android:layout_marginTop="61dp"
android:text="Email"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/settings_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/settings_display_name"
android:layout_below="#+id/settings_email"
android:layout_marginTop="62dp"
android:layout_centerHorizontal="true"
android:text="Decription"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/settings_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/settings_description"
android:layout_centerHorizontal="true"
android:layout_marginTop="80dp"
android:text="Address"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/settings_edit_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignBottom="#+id/settings_description"
android:layout_marginStart="37dp"
android:layout_toEndOf="#+id/settings_description"
android:drawableStart="#drawable/ic_mode_edit_white_18dp" />
<TextView
android:id="#+id/settings_edit_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignBottom="#+id/settings_address"
android:layout_alignStart="#+id/settings_edit_description"
android:drawableStart="#drawable/ic_mode_edit_white_18dp" />
<Button
android:id="#+id/EditPassBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="31dp"
android:backgroundTint="#color/colorAccent"
android:text="Change Password"
android:textColor="#android:color/black" />
I am trying to create a scrollable list with ratingbars and textviews.
However I am unable to get them to align correctly. I would like even spacing between all textviews and rating bars..
I have tried to use the layout_below but this does not produce what I would like, I have also tried dragging, but this also does not create the wanted effect.
Any help would be appreciated :)
<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/colorPrimaryDark"
tools:context="uk.co.neverendingsport.neverendingsport.LoginActivity">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Continue"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="13dp"
android:id="#+id/button" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select Sports"
android:textSize="30sp"
android:textStyle="bold"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="#+id/textView4"
android:layout_alignParentStart="true">
<TextView
android:id="#+id/footballTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Football"
android:textSize="30sp"
android:layout_above="#+id/cyclingRatingBar"
android:layout_alignParentStart="true" />
<RatingBar
android:id="#+id/footballRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/cyclingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cycling"
android:textSize="30sp"
android:layout_above="#+id/badmintonTextView"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp" />
<RatingBar
android:id="#+id/cyclingRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/footballRatingBar"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/badmintonTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Badminton"
android:textSize="30sp"
android:layout_below="#+id/cyclingRatingBar"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/badmintonRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/runningTextView"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/runningTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Running"
android:textSize="30sp"
android:layout_below="#+id/badmintonTextView"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/runningRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/badmintonRatingBar"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/swimmingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Swimming"
android:textSize="30sp"
android:layout_below="#+id/runningTextView"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/swimmingRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/runningRatingBar"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/golfTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Golf"
android:textSize="30sp"
android:layout_below="#+id/swimmingTextView"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/golfRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/swimmingRatingBar"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</RelativeLayout>
Image of current layout
Here is the answer that works fine for me
<?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">
<TextView
android:id="#+id/textView2"
style="#style/Base.TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Select Sports" />
<TextView
android:id="#+id/textView6"
style="#style/Base.TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/ratingBar"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="17dp"
android:layout_toLeftOf="#+id/ratingBar"
android:layout_toStartOf="#+id/ratingBar"
android:text="Football" />
<RatingBar
android:id="#+id/ratingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/textView2" />
<RatingBar
android:id="#+id/ratingBar2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/ratingBar" />
<RatingBar
android:id="#+id/ratingBar3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/ratingBar2"
android:layout_alignStart="#+id/ratingBar2"
android:layout_below="#+id/ratingBar2" />
<RatingBar
android:id="#+id/ratingBar4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/ratingBar3"
android:layout_alignStart="#+id/ratingBar3"
android:layout_below="#+id/ratingBar3" />
<TextView
android:id="#+id/textView7"
style="#style/Base.TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/ratingBar3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="17dp"
android:layout_toLeftOf="#+id/textView2"
android:text="Cycling" />
<TextView
android:id="#+id/textView8"
style="#style/Base.TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/ratingBar4"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="14dp"
android:layout_toLeftOf="#+id/ratingBar3"
android:text="Badminton" />
<TextView
android:id="#+id/textView9"
style="#style/Base.TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/ratingBar4"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="16dp"
android:layout_toLeftOf="#+id/ratingBar4"
android:text="Running" />
</RelativeLayout>]
final output
First of all you need to add rating bar to parent layout and later textview to the parent layout
Try this
<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/colorPrimaryDark"
tools:context="uk.co.neverendingsport.neverendingsport.LoginActivity">
<Button
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="13dp"
android:text="Continue" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Select Sports"
android:textSize="30sp"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_below="#+id/textView4">
<RelativeLayout
android:id="#+id/relativeFootball"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/footballTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Football"
android:textSize="30sp" />
<RatingBar
android:id="#+id/footballRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeCycle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeFootball">
<TextView
android:id="#+id/cyclingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Cycling"
android:textSize="30sp" />
<RatingBar
android:id="#+id/cyclingRatingBar"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeBadminton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeCycle">
<TextView
android:id="#+id/badmintonTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Badminton"
android:textSize="30sp" />
<RatingBar
android:id="#+id/badmintonRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeRunning"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeBadminton">
<TextView
android:id="#+id/runningTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Running"
android:textSize="30sp" />
<RatingBar
android:id="#+id/runningRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeSwimming"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeRunning">
<TextView
android:id="#+id/swimmingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:text="Swimming"
android:textSize="30sp" />
<RatingBar
android:id="#+id/swimmingRatingBar"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeGolf"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeSwimming">
<TextView
android:id="#+id/golfTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Golf"
android:textSize="30sp" />
<RatingBar
android:id="#+id/golfRatingBar"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimaryDark"
>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Continue"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="13dp"
android:id="#+id/button" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select Sports"
android:textSize="28sp"
android:textStyle="bold"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView4"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="#+id/footballTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Football"
android:textSize="28sp"
android:layout_weight="1"
android:layout_above="#+id/cyclingRatingBar"
/>
<RatingBar
android:id="#+id/footballRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="#+id/cyclingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cycling"
android:textSize="28sp"
android:layout_weight="1"
android:layout_above="#+id/badmintonTextView"
android:layout_marginBottom="10dp" />
<RatingBar
android:id="#+id/cyclingRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/footballRatingBar"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="#+id/badmintonTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Badminton"
android:textSize="28sp"
android:layout_below="#+id/cyclingRatingBar"
android:layout_weight="1"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/badmintonRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/runningTextView"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="#+id/runningTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Running"
android:textSize="28sp"
android:layout_weight="1"
android:layout_below="#+id/badmintonTextView"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/runningRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/badmintonRatingBar"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="#+id/swimmingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Swimming"
android:textSize="28sp"
android:layout_weight="1"
android:layout_below="#+id/runningTextView"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/swimmingRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/runningRatingBar"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="#+id/golfTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Golf"
android:textSize="28sp"
android:layout_weight="1"
android:layout_below="#+id/swimmingTextView"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/golfRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/swimmingRatingBar"
>
</RatingBar>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
My scrollview on my .xml is working but it's overlapping on the toolbar I can't press back on the hierarchy anymore and also I just updated my android studio to 2.2 Beta idk if this is the problem.
Here it is.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<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:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.example.kun.carkila.DetailActivity"
tools:showIn="#layout/activity_detail">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/etResDate"
android:editable="false"
android:hint="Reservation Date"
android:layout_below="#+id/etPickup"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/etResTime"
android:editable="false"
android:hint="Reservation Time"
android:layout_below="#+id/etResDate"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/etPickup"
android:hint="Pickup Location"
android:layout_below="#+id/tvPoster"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="22dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/etReturnTime"
android:editable="false"
android:hint="Return Time"
android:layout_below="#+id/etReturnDate"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rent"
android:id="#+id/btnRent"
android:layout_below="#+id/etReturnTime"
android:layout_centerHorizontal="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/ivImage"
android:src="#android:drawable/star_big_on"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/tvCarModel"
android:layout_below="#+id/ivImage"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/tvCarType"
android:layout_below="#+id/tvCarModel"
android:layout_alignLeft="#+id/tvCarModel"
android:layout_alignStart="#+id/tvCarModel" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/tvCapacity"
android:layout_below="#+id/tvCarType"
android:layout_alignLeft="#+id/tvCarType"
android:layout_alignStart="#+id/tvCarType" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/tvFuelType"
android:layout_below="#+id/tvCapacity"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/tvPoster"
android:layout_below="#+id/tvPlateNumber"
android:layout_alignLeft="#+id/tvPlateNumber"
android:layout_alignStart="#+id/tvPlateNumber" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/tvPlateNumber"
android:layout_below="#+id/tvFuelType"
android:layout_alignLeft="#+id/tvFuelType"
android:layout_alignStart="#+id/tvFuelType" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/etReturnDate"
android:editable="false"
android:hint="Return Date"
android:layout_below="#+id/etResTime"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
Remove this app:layout_behavior="#string/appbar_scrolling_view_behavior" from Relative Layout.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<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:orientation="vertical"
tools:context="com.example.kun.carkila.DetailActivity"
tools:showIn="#layout/activity_detail">
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<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:orientation="vertical"
tools:context="com.example.kun.carkila.DetailActivity">
<EditText
android:id="#+id/etResDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/etPickup"
android:editable="false"
android:hint="Reservation Date" />
<EditText
android:id="#+id/etResTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/etResDate"
android:editable="false"
android:hint="Reservation Time" />
<EditText
android:id="#+id/etPickup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/tvPoster"
android:layout_marginTop="22dp"
android:ems="10"
android:hint="Pickup Location"
android:inputType="textPersonName" />
<EditText
android:id="#+id/etReturnTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/etReturnDate"
android:editable="false"
android:hint="Return Time" />
<Button
android:id="#+id/btnRent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/etReturnTime"
android:layout_centerHorizontal="true"
android:text="Rent" />
<ImageView
android:id="#+id/ivImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="#android:drawable/star_big_on" />
<TextView
android:id="#+id/tvCarModel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ivImage"
android:layout_centerHorizontal="true"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/tvCarType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvCarModel"
android:layout_alignStart="#+id/tvCarModel"
android:layout_below="#+id/tvCarModel"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/tvCapacity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvCarType"
android:layout_alignStart="#+id/tvCarType"
android:layout_below="#+id/tvCarType"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/tvFuelType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tvCapacity"
android:layout_centerHorizontal="true"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/tvPoster"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvPlateNumber"
android:layout_alignStart="#+id/tvPlateNumber"
android:layout_below="#+id/tvPlateNumber"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/tvPlateNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvFuelType"
android:layout_alignStart="#+id/tvFuelType"
android:layout_below="#+id/tvFuelType"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/etReturnDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/etResTime"
android:editable="false"
android:hint="Return Date" />
</RelativeLayout>
</ScrollView>
check if this helps
Please do something like the XML code below or just simply add your EditText/TextView component in between NestedScrollView.
<?xml version="1.0" encoding="utf-8"?>
<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/addtimesheetlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.kun.carkila.DetailActivity"
android:orientation="vertical">
<android.support.v4.widget.NestedScrollView
android:id="#+id/scrollableview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<!--Add your EditText here-->
</LinearLayout><!--Main layout ends-->
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
I am trying to align my buttons at the bottom of the screen using layouts but I cannot figure what's wrong with my code. I have tried several options by nesting different layouts but with no good outcome. it looks like this right now
And my code:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView01"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/relLayout"
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:clickable="true"
android:focusableInTouchMode="true"
tools:context="com.example.aurora.personalinformation.MainActivity">
<!-- Make the parent view clickable and focusable -->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/title"
android:layout_centerHorizontal="true"
android:id="#+id/title"
android:textColor="#FF0000"
android:textSize="25dp"
android:textAlignment="center" />
<TextView
android:id="#+id/nameLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/name"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="15dp"
android:layout_marginTop="40dp"
android:layout_below="#id/title"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<EditText android:id="#+id/edit_name"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter name"
android:layout_alignBottom="#id/nameLable"
android:layout_toRightOf="#+id/phoneLable"
android:layout_toEndOf="#+id/phoneLable"
/>
<TextView
android:id="#+id/addressLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/address"
android:textColor="#000000"
android:textSize="15dp"
android:textStyle="bold"
android:layout_alignBottom="#+id/addressField"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<EditText
android:id="#+id/addressField"
android:layout_weight="0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter your address"
android:layout_below="#id/edit_name"
android:layout_alignLeft="#id/edit_name"
android:layout_alignStart="#id/edit_name" />
<TextView
android:id="#+id/phoneLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/phone"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="15dp"
android:layout_below="#id/addressField"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="20dp"/>
<EditText
android:id="#+id/phoneField"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter your phone number"
android:layout_below="#id/addressField"
android:layout_toRightOf="#id/phoneLable"
android:layout_toEndOf="#id/phoneLable" />
<TextView
android:id="#+id/emailLable"
android:layout_below="#id/phoneLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/email"
android:textColor="#000000"
android:textSize="15dp"
android:textStyle="bold"
android:layout_marginTop="20dp"/>
<EditText
android:id="#+id/emailField"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter your email"
android:layout_below="#id/phoneField"
android:layout_alignLeft="#id/phoneField"
android:layout_alignStart="#id/phoneField" />
<TextView
android:id="#+id/genderLable"
android:layout_below="#id/emailLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/gender"
android:layout_marginTop="20dp"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="15dp" />
<Spinner
android:id="#+id/gender"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:entries="#array/gender"
android:layout_alignTop="#+id/genderLable"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignLeft="#+id/emailField"
android:layout_alignStart="#+id/emailField" />
<TextView
android:id="#+id/country"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Country"
android:textColor="#000000"
android:textSize="15dp"
android:textStyle="bold"
android:layout_below="#id/gender"
android:layout_marginTop="15dp"/>
<AutoCompleteTextView
android:id="#+id/countryField"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter your email"
android:layout_below="#id/gender"
android:layout_toRightOf="#id/phoneLable"
android:layout_toEndOf="#id/phoneLable" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="bottom"
android:layout_alignParentBottom="true">
<Button
android:id="#+id/buttonSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:id="#+id/buttonCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
just give your last RelativeLayout like this:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="bottom"
android:layout_below="#+id/countryField"
android:layout_alignParentBottom="true">
<Button
android:id="#+id/buttonSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:id="#+id/buttonCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
One more thing there is no meaning to give an orientation to RelativeLayout.
I have a floating action button over a listview, but I can't click on the button when the list fills up so that the button and the list overlap. In that situation only the list item is clickable. How do I rectify this issue? Thanks in advance. My xml code is below.
<?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">
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
card_view:cardCornerRadius="1dp"
card_view:cardElevation="5dp">
<RelativeLayout
android:id="#+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/frameLayout"
android:layout_centerHorizontal="true"
android:layout_gravity="bottom"
android:background="#000000"
android:orientation="vertical"
android:padding="1.5dp"
android:weightSum="1">
<TextView
android:id="#+id/txtTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="#660033"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/primary_text_dark" />
<RelativeLayout
android:id="#+id/frameLayout"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="29dp"
android:background="#android:color/darker_gray"
android:padding="2dp">
<TextView
android:id="#+id/txtLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/dispLoc"
android:layout_gravity="left|top"
android:text="[Location]"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/txtDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/dispDesc"
android:layout_gravity="left|center_vertical"
android:layout_marginTop="1dp"
android:text="[Description]"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/dispLoc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text="#string/loc"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/dispDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/txtLocation"
android:layout_gravity="left|center_vertical"
android:layout_marginTop="17dp"
android:text="#string/desc"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/dispContact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/txtDesc"
android:layout_marginTop="25dp"
android:text="#string/contact"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/txtContact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/dispContact"
android:layout_toEndOf="#+id/dispLoc"
android:autoLink="email"
android:text="[ContactInfo]"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/From"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/dispContact"
android:layout_marginTop="16dp"
android:text="#string/from"
android:textColor="#android:color/primary_text_light" />
<TextView
android:id="#+id/txtStartDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/From"
android:layout_marginLeft="10dp"
android:layout_toEndOf="#+id/From"
android:text="[Start Date]"
android:textColor="#android:color/secondary_text_light" />
<TextView
android:id="#+id/To"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/txtStartDate"
android:text="#string/to"
android:textColor="#android:color/primary_text_light" />
<TextView
android:id="#+id/txtEndDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/txtStartDate"
android:layout_alignTop="#+id/To"
android:text="[End Date]"
android:textColor="#android:color/secondary_text_light" />
<Button
android:id="#+id/attend_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:text="Attend" />
<Button
android:id="#+id/cancel_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignStart="#+id/txtContact"
android:text="Cancel" />
</RelativeLayout>
<TextView
android:id="#+id/txtType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/txtTitle"
android:layout_alignEnd="#+id/txtTitle"
android:text="Type"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/primary_text_dark" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<TextView
android:id="#+id/peopleAttending"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/card_view"
android:background="#660033"
android:text="#string/people_attending"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/primary_text_dark" />
<org.lucasr.twowayview.TwoWayView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/lvItems"
style="#style/TwoWayView"
android:layout_width="match_parent"
android:layout_height="37dp"
android:layout_below="#+id/peopleAttending"
android:drawSelectorOnTop="false"
tools:context=".DetailedEventActivity" />
<com.software.shell.fab.ActionButton xmlns:fab="http://schemas.android.com/apk/res-auto"
android:id="#+id/action_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="#dimen/fab_margin"
android:layout_marginEnd="#dimen/fab_margin"
fab:button_color="#color/fab_material_red_500"
fab:button_colorPressed="#color/fab_material_red_900"
fab:hide_animation="#anim/fab_roll_to_down"
fab:image="#drawable/fab_plus_icon"
fab:image_size="24dp"
fab:shadow_color="#757575"
fab:shadow_radius="1.0dp"
fab:shadow_xOffset="0.5dp"
fab:shadow_yOffset="1.0dp"
fab:show_animation="#anim/fab_roll_from_down"
fab:stroke_color="#color/fab_material_blue_grey_500"
fab:stroke_width="1.0dp"
fab:type="DEFAULT"
android:clickable="true"/>
<ListView
android:id="#+id/commentsList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/lvItems"
android:layout_marginTop="0dp"
/>
Move your FAB to the bottom of the XML (below the ListView).