The problem is when I am tapping on floating image button the background layout is also call.
I have below attached the code also.
<RelativeLayout
android:background="#color/white"
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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<TextView
android:textColor="#color/md_black_1000"
android:textAppearance="#style/TextAppearance.AppCompat.Large"
android:text="Today Date"
android:id="#+id/today_date"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:layout_below="#+id/today_date"
android:orientation="vertical" >
<LinearLayout
android:orientation="horizontal"
android:layout_weight="1.7"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_weight="1"
android:gravity="center"
android:textColor="#color/md_black_1000"
android:text="Morning"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:gravity="center"
android:layout_weight="1"
android:textColor="#color/md_black_1000"
android:text="Afternoon"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:orientation="horizontal" >
<LinearLayout
android:orientation="horizontal"
android:layout_marginBottom="#dimen/activity_vertical_margin"
android:layout_marginEnd="#dimen/activity_vertical_margin"
android:id="#+id/ll1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/rectangle"
android:layout_weight="1.0"
android:text="Morning" />
<LinearLayout
android:orientation="horizontal"
android:layout_marginBottom="#dimen/activity_vertical_margin"
android:layout_marginEnd="#dimen/activity_vertical_margin"
android:id="#+id/ll2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/rectangle"
android:layout_weight="1.0"
android:text="Afternoon" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_weight="1.7"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_weight="1"
android:gravity="center"
android:textColor="#color/md_black_1000"
android:text="Evening"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:gravity="center"
android:layout_weight="1"
android:textColor="#color/md_black_1000"
android:text="Night"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:weightSum="2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:orientation="horizontal" >
<LinearLayout
android:orientation="horizontal"
android:layout_marginBottom="#dimen/activity_vertical_margin"
android:layout_marginEnd="#dimen/activity_vertical_margin"
android:id="#+id/ll3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/rectangle"
android:layout_weight="1.0"
android:text="evening" />
<LinearLayout
android:orientation="horizontal"
android:layout_marginBottom="#dimen/activity_vertical_margin"
android:layout_marginEnd="#dimen/activity_vertical_margin"
android:id="#+id/ll4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/rectangle"
android:layout_weight="1.0"
android:text="Night" />
</LinearLayout>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_add_reminders"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_plus"
app:backgroundTint="#ffffff"
android:layout_marginBottom="18dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="0dp" />
</RelativeLayout>
If anyone need other code I am happy to provide you. I am not able to figure out why it is clashes with the background activity.
<RelativeLayout
android:id="#+id/root_layout"
android:background="#color/white"
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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<TextView
android:textColor="#color/md_black_1000"
android:textAppearance="#style/TextAppearance.AppCompat.Large"
android:text="Today Date"
android:id="#+id/today_date"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:layout_below="#+id/today_date"
android:orientation="vertical" >
<LinearLayout
android:orientation="horizontal"
android:layout_weight="1.7"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_weight="1"
android:gravity="center"
android:textColor="#color/md_black_1000"
android:text="Morning"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:gravity="center"
android:layout_weight="1"
android:textColor="#color/md_black_1000"
android:text="Afternoon"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:orientation="horizontal" >
<LinearLayout
android:orientation="horizontal"
android:layout_marginBottom="#dimen/activity_vertical_margin"
android:layout_marginEnd="#dimen/activity_vertical_margin"
android:id="#+id/ll1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/rectangle"
android:layout_weight="1.0"
android:text="Morning" />
<LinearLayout
android:orientation="horizontal"
android:layout_marginBottom="#dimen/activity_vertical_margin"
android:layout_marginEnd="#dimen/activity_vertical_margin"
android:id="#+id/ll2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/rectangle"
android:layout_weight="1.0"
android:text="Afternoon" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_weight="1.7"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_weight="1"
android:gravity="center"
android:textColor="#color/md_black_1000"
android:text="Evening"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:gravity="center"
android:layout_weight="1"
android:textColor="#color/md_black_1000"
android:text="Night"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:weightSum="2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:orientation="horizontal" >
<LinearLayout
android:orientation="horizontal"
android:layout_marginBottom="#dimen/activity_vertical_margin"
android:layout_marginEnd="#dimen/activity_vertical_margin"
android:id="#+id/ll3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/rectangle"
android:layout_weight="1.0"
android:text="evening" />
<LinearLayout
android:orientation="horizontal"
android:layout_marginBottom="#dimen/activity_vertical_margin"
android:layout_marginEnd="#dimen/activity_vertical_margin"
android:id="#+id/ll4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/rectangle"
android:layout_weight="1.0"
android:text="Night" />
</LinearLayout>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_add_reminders"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_plus"
app:backgroundTint="#ffffff"
android:layout_marginBottom="18dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="0dp" />
</RelativeLayout>
In Activity
FloatingActionButton btn ;//Assume find view by Id
RelativeLayout rl ;//Assume find view by Id
rl.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//Keep Empty
}
});
btn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//do your code
}
});
Try it will help you out
Related
I added a ListView with a collapsing toolbar at the top and bottom navigation at the bottom.
My problem is that the bottom navigation keeps hiding when scrolling up. I want it to stay visible.
I enabled nested scrolling programmatically. I tried many solutions, none of them worked.
This is my problem and my XML at the bottom:
This my main.xml
<androidx.coordinatorlayout.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:id="#+id/_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/_app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="#+id/collapse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="#000000"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|enterAlways|snap">
<LinearLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:gravity="center_horizontal|center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/textview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="collapsing toolbar"
android:textSize="20sp"
android:textColor="#FFFFFF"/>
</LinearLayout>
<androidx.appcompat.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"/>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<ListView
android:id="#+id/listview1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:choiceMode="none"
android:layout_weight="1"/>
<LinearLayout
android:id="#+id/nav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:background="#1565C0"
android:gravity="center_horizontal|center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/textview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="bottom navigation"
android:textSize="20sp"
android:textColor="#FFFFFF"/>
</LinearLayout>
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
use a ConstraintLayout as a Root ViewGroup, and wrap in it the CoordinatorLayout, and the BottomNavigation
Then you can need to add some padding at the end of the ListView
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="#+id/_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/_app_bar"
android:layout_width="match_parent"
android:theme="#style/AppTheme.AppBarOverlay"
android:layout_height="wrap_content">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="#+id/collapse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:contentScrim="#000000"
app:layout_scrollFlags="scroll|enterAlways|snap">
<androidx.appcompat.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"/>
<LinearLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:orientation="horizontal"
android:padding="8dp">
<TextView
android:id="#+id/textview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="collapsing toolbar"
android:textColor="#FFFFFF"
android:textSize="20sp" />
</LinearLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<ListView
android:id="#+id/listview1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="none"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<LinearLayout
android:id="#+id/nav"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#1565C0"
android:gravity="center"
android:orientation="horizontal"
android:padding="8dp"
app:layout_constraintBottom_toBottomOf="parent">
<TextView
android:id="#+id/textview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="bottom navigation"
android:textColor="#FFFFFF"
android:textSize="20sp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
RelativeLayout version
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="#+id/_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/_app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="#+id/collapse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:contentScrim="#000000"
app:layout_scrollFlags="scroll|enterAlways|snap">
<androidx.appcompat.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" />
<LinearLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:orientation="horizontal"
android:padding="8dp">
<TextView
android:id="#+id/textview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="collapsing toolbar"
android:textColor="#FFFFFF"
android:textSize="20sp" />
</LinearLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<ListView
android:id="#+id/listview1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="none"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<LinearLayout
android:id="#+id/nav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#1565C0"
android:gravity="center"
android:orientation="horizontal"
android:padding="8dp"
app:layout_constraintBottom_toBottomOf="parent">
<TextView
android:id="#+id/textview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="bottom navigation"
android:textColor="#FFFFFF"
android:textSize="20sp" />
</LinearLayout>
</RelativeLayout>
Preview (replace ListView with NestedScrollView for simplicity)
I am trying show fab more button inside the nested scroll view.I have searched for many solutions but not found any solution which I can able to show fab more button in right bottom
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:fitsSystemWindows="true"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageButton
android:id="#+id/bt_close"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:background="?attr/selectableItemBackgroundBorderless"
android:tint="#android:color/white"
app:srcCompat="#drawable/ic_close" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="Filter All Order"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Title"
android:textColor="#android:color/white" />
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:scrollingCache="true">
<LinearLayout
android:id="#+id/billBlock"
android:layout_width="match_parent"
android:layout_height="match_parent">
//many inner layout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="#color/grey_10" />
<android.support.v7.widget.RecyclerView
android:id="#+id/print_payment_list"
android:layout_margin="10dp"
android:background="#color/grey_20"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:id="#+id/fabFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
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:orientation="vertical">
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_mic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/spacing_middle"
android:clickable="true"
android:tint="#color/grey_80"
app:backgroundTint="#color/grey_20"
app:fabSize="mini"
app:rippleColor="#android:color/white"
app:srcCompat="#drawable/ic_mic" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/spacing_middle"
android:clickable="true"
android:tint="#color/grey_80"
app:backgroundTint="#color/grey_20"
app:fabSize="mini"
app:rippleColor="#android:color/white"
app:srcCompat="#drawable/ic_photo_camera" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/spacing_smlarge"
android:layout_marginLeft="#dimen/spacing_smlarge"
android:layout_marginRight="#dimen/spacing_smlarge"
android:layout_marginTop="#dimen/spacing_middle"
android:clickable="true"
android:tint="#android:color/white"
app:fabSize="normal"
app:rippleColor="#android:color/white"
app:srcCompat="#drawable/ic_add" />
<!--android:src="#drawable/ic_close_black_24dp"-->
</FrameLayout>
</LinearLayout>
I have multiple views inside one parent of nested scroll view .scroll and all working fine .only issue is fab is not positioned in a bottom right position
can anyone help me how I can achieve this? since am new to android.T hanks
i need fab bar to be placed like this .This is sample image from google
try this one
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:fitsSystemWindows="true"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="#+id/app"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageButton
android:id="#+id/bt_close"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:background="?attr/selectableItemBackgroundBorderless"
android:tint="#android:color/white"
app:srcCompat="#drawable/ic_close" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="Filter All Order"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Title"
android:textColor="#android:color/white" />
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_below="#id/app"
android:layout_above="#+id/fabFrame"
android:layout_height="match_parent"
android:scrollbars="none"
android:scrollingCache="true">
<LinearLayout
android:id="#+id/billBlock"
android:layout_width="match_parent"
android:layout_height="match_parent">
//many inner layout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="#color/grey_10" />
<android.support.v7.widget.RecyclerView
android:id="#+id/print_payment_list"
android:layout_margin="10dp"
android:background="#color/grey_20"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<FrameLayout
android:id="#+id/fabFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="?attr/actionBarSize"
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:orientation="vertical">
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_mic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/spacing_middle"
android:clickable="true"
android:tint="#color/grey_80"
app:backgroundTint="#color/grey_20"
app:fabSize="mini"
app:rippleColor="#android:color/white"
app:srcCompat="#drawable/ic_mic" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/spacing_middle"
android:clickable="true"
android:tint="#color/grey_80"
app:backgroundTint="#color/grey_20"
app:fabSize="mini"
app:rippleColor="#android:color/white"
app:srcCompat="#drawable/ic_photo_camera" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/spacing_smlarge"
android:layout_marginLeft="#dimen/spacing_smlarge"
android:layout_marginRight="#dimen/spacing_smlarge"
android:layout_marginTop="#dimen/spacing_middle"
android:clickable="true"
android:tint="#android:color/white"
app:fabSize="normal"
app:rippleColor="#android:color/white"
app:srcCompat="#drawable/ic_add" />
<!--android:src="#drawable/ic_close_black_24dp"-->
</FrameLayout>
</RelativeLayout>
Always used linear layout for continuous Views and use Framelayout or Relative Layout when you what to show something position like right or bottom.
I have created a scrollview in Linear Layout . on 23 api or above its working fine but on below api the screen does not work and also it does not throw any exception. I am using this scrollview in fragment.I also got same issue in recyclerview .Is there any supported library issue or something else.
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_marginTop="#dimen/_2sdp"
android:weightSum="10"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="#dimen/_130sdp">
<LinearLayout
android:layout_weight="4.9"
android:layout_width="0dp"
android:layout_height="match_parent">
<Button
android:id="#+id/underwaterpark"
android:background="#drawable/underwatertunnel"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_weight="0.2"
android:layout_width="0dp"
android:layout_height="match_parent"></LinearLayout>
<LinearLayout
android:layout_weight="4.9"
android:layout_width="0dp"
android:layout_height="match_parent">
<Button
android:id="#+id/aquadam"
android:background="#drawable/aqua_dam"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_marginTop="#dimen/_3sdp"
android:weightSum="10"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="#dimen/_130sdp">
<LinearLayout
android:layout_weight="4.9"
android:layout_width="0dp"
android:layout_height="match_parent">
<Button
android:id="#+id/suites"
android:background="#drawable/deluxsuite"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_weight="0.2"
android:layout_width="0dp"
android:layout_height="match_parent"></LinearLayout>
<LinearLayout
android:layout_weight="4.9"
android:layout_width="0dp"
android:layout_height="match_parent">
<Button
android:id="#+id/marine"
android:background="#drawable/marinethemedresturant"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_marginTop="#dimen/_3sdp"
android:weightSum="10"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="#dimen/_130sdp">
<LinearLayout
android:layout_weight="4.9"
android:layout_width="0dp"
android:layout_height="match_parent">
<Button
android:id="#+id/pool"
android:background="#drawable/infinitypool"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_weight="0.2"
android:layout_width="0dp"
android:layout_height="match_parent"></LinearLayout>
<LinearLayout
android:layout_weight="4.9"
android:layout_width="0dp"
android:layout_height="match_parent">
<Button
android:id="#+id/waterpark"
android:background="#drawable/indoorwaterpark"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_marginTop="#dimen/_3sdp"
android:layout_marginBottom="#dimen/_2sdp"
android:weightSum="10"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="#dimen/_130sdp">
<LinearLayout
android:layout_weight="4.9"
android:layout_width="0dp"
android:layout_height="match_parent">
<Button
android:id="#+id/apartments"
android:background="#drawable/apartmentswithlawn"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_weight="0.2"
android:layout_width="0dp"
android:layout_height="match_parent"></LinearLayout>
<LinearLayout
android:layout_weight="4.9"
android:layout_width="0dp"
android:layout_height="match_parent">
<Button
android:id="#+id/helipad"
android:background="#drawable/ehelipad"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
I have updated this XML Code try once this :-
<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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="130dp"
android:layout_marginTop="2dp"
android:orientation="horizontal"
android:weightSum="10">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4.9">
<Button
android:id="#+id/underwaterpark"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ic_launcher_background" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"></LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4.9">
<Button
android:id="#+id/aquadam"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ic_launcher_background" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="130dp"
android:layout_marginTop="3dp"
android:orientation="horizontal"
android:weightSum="10">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4.9">
<Button
android:id="#+id/suites"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ic_launcher_background" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"></LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4.9">
<Button
android:id="#+id/marine"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ic_launcher_background" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="130dp"
android:layout_marginTop="3dp"
android:orientation="horizontal"
android:weightSum="10">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4.9">
<Button
android:id="#+id/pool"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ic_launcher_background" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"></LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4.9">
<Button
android:id="#+id/waterpark"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ic_launcher_background" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="130dp"
android:layout_marginBottom="2dp"
android:layout_marginTop="3dp"
android:orientation="horizontal"
android:weightSum="10">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4.9">
<Button
android:id="#+id/apartments"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ic_launcher_background" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"></LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4.9">
<Button
android:id="#+id/helipad"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ic_launcher_background" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
Try this out,
android:fillViewport="true"
for eg:
<ScrollView
android:layout_width="match_parent"
android:fillViewport="true"
android:layout_height="wrap_content">
</ScrollView>
it may help you.
Ypu are using fill_parent which is deprecated now you should use match_parent
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
Change it to
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" // you can add this line too but it should work without it
>
am getting 2 error like this in android studio, since i can build and run the app under debug mode i cant generate a signed apk!
Error: #id/profileListView is not a sibling in the same RelativeLayout [NotSibling]
this is the code :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
android:orientation="vertical"
android:id="#+id/main_layout"
tools:context="com.citsleb.market.ProfileFragment" >
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/profileContainer" >
<android.support.v4.widget.SwipeRefreshLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/profileContentScreen"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_width="match_parent" >
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/profileListView"
android:fillViewport="false"
android:scrollbars="none"
android:headerDividersEnabled="true"
android:divider="#color/listViewDivider"
android:dividerHeight="8dp"
android:background="#color/listViewDivider">
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/profileDisabledScreen">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:padding="20dp"
android:id="#+id/profileDisabledScreenContent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/label_account_disabled"
android:id="#+id/profileDisabledScreenMsg"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:textSize="16dp"
android:textStyle="bold"
android:textColor="#color/dark_blue" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/profileErrorScreen"
android:longClickable="false">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/error_data_loading"
android:id="#+id/profileErrorScreenMsg"
android:layout_centerHorizontal="true"
android:gravity="center"
android:textColor="#color/gray"
android:singleLine="false"
android:textSize="18dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:layout_centerVertical="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/profileLoadingScreen">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/profileLoadingScreenProgressBar"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<com.melnykov.fab.FloatingActionButton
android:id="#+id/fabButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:layout_marginRight="24dp"
android:src="#drawable/ic_action_new"
app:fabSize="normal"
app:layout_anchor="#id/profileListView"
android:elevation="2dp"
android:layout_marginEnd="41dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
fab:fab_colorNormal="#color/colorFloatActionButton"
fab:fab_colorPressed="#color/colorFloatActionButton"
fab:fab_colorRipple="#color/colorRipple" />
i just solved it by adding this to buil.gradle
lintOptions {
checkReleaseBuilds false
abortOnError false
Is there any problem with this?
Thanks
I am trying to build this layout
But I am getting this: (The map button in the location would be ideal height and width but the textview doesn't match the height)
My location is a TextView and my destination is a EditText
I want the TextView and EditText to be the same width while the MAP buttons stay "square".
How can I get the textviews height to match and make a square map button?
Here is my layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/fragment_details"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.mycompany.controller.DetailsFragment">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/viewStatus"
android:layout_marginTop="5dp">
<LinearLayout
android:id="#+id/scrollViewDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- LOCATION -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="LOCATION"
android:textColor="#color/COLOR_BLUE"
android:textSize="24sp"/>
<LinearLayout
android:id="#+id/layoutLocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/tvLocation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_weight=".8"
android:background="#color/COLOR_LIGHT_GREY"
android:text="123 MAIN ST., CHATTANOOGA TN 37404"
android:textSize="24sp"/>
<Button
android:id="#+id/btnMapLocation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight=".2"
android:background="#color/COLOR_BLUE"
android:text="MAP"
android:textColor="#color/COLOR_WHITE"/>
</LinearLayout>
<!-- DESTINATION -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="DESTINATION"
android:textColor="#color/COLOR_BLUE"
android:textSize="24sp"/>
<LinearLayout
android:id="#+id/layoutDestination"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/editDestination"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight=".8"
android:ems="10"
android:inputType="textMultiLine"
android:text="407 Broad St., Anywhere ST 00000"/>
<Button
android:id="#+id/btnMapDestination"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight=".2"
android:background="#color/COLOR_BLUE"
android:text="MAP"
android:textColor="#color/COLOR_WHITE"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
I did a slight modification in your code check it!
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/fragment_details"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp">
<LinearLayout
android:id="#+id/scrollViewDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- LOCATION -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="LOCATION"
android:textSize="24sp"/>
<LinearLayout
android:id="#+id/layoutLocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/searchText"
android:text="Search text here"
android:layout_weight="0.8"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="#c8c8c8"
/>
<Button
android:id="#+id/searchButton"
android:text="MAP"
android:layout_weight="0.2"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
/>
</LinearLayout>
<!-- DESTINATION -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="DESTINATION"
android:textSize="24sp"/>
<LinearLayout
android:id="#+id/layoutLocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/searchText"
android:text="Search text"
android:layout_weight="0.8"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
<Button
android:id="#+id/searchButton"
android:text="MAP"
android:layout_weight="0.2"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
Since you are using android:layout_weight, set android:layout_width="0dp"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/fragment_details"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.mycompany.controller.DetailsFragment">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/viewStatus"
android:layout_marginTop="5dp">
<LinearLayout
android:id="#+id/scrollViewDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- LOCATION -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="LOCATION"
android:textColor="#color/COLOR_BLUE"
android:textSize="24sp"/>
<LinearLayout
android:id="#+id/layoutLocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/tvLocation"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_weight=".8"
android:background="#color/COLOR_LIGHT_GREY"
android:text="123 MAIN ST., CHATTANOOGA TN 37404"
android:textSize="24sp"/>
<Button
android:id="#+id/btnMapLocation"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".2"
android:background="#color/COLOR_BLUE"
android:text="MAP"
android:textColor="#color/COLOR_WHITE"/>
</LinearLayout>
<!-- DESTINATION -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="DESTINATION"
android:textColor="#color/COLOR_BLUE"
android:textSize="24sp"/>
<LinearLayout
android:id="#+id/layoutDestination"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/editDestination"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".8"
android:ems="10"
android:inputType="textMultiLine"
android:text="407 Broad St., Anywhere ST 00000"/>
<Button
android:id="#+id/btnMapDestination"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".2"
android:background="#color/COLOR_BLUE"
android:text="MAP"
android:textColor="#color/COLOR_WHITE"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>