HorizontalScrollView stay on top - android

I have activity with horizontal scroll view to display four button's. Below located FrameLayout witch display fragment based on what button was clicked. Second and Fourth button shows RecyclerView with a lot of data. How can i make this horizontal scroll view to stay on top below or in place of Toolbar, so i can switch between fragments withount going all the way up?
<androidx.constraintlayout.widget.ConstraintLayout 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/smoky_white"
android:orientation="vertical"
tools:context=".o_kaznau">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/purple_200"
android:elevation="4dp"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:title="О КазНАИУ" />
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/toolbar"
app:layout_constraintVertical_bias="1.0">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView11"
android:layout_width="match_parent"
android:layout_height="230dp"
android:scaleType="fitXY"
android:src="#drawable/im_maincorpus1"/>
<HorizontalScrollView
android:id="#+id/horizontalScrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:id="#+id/btnAbout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/about_btn"
android:onClick="aboutAbout"
android:textSize="15sp"
android:textAllCaps="false"
android:text="Об университете" />
<Button
android:id="#+id/btnRyk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/about_btn"
android:onClick="aboutRyc"
android:textSize="15sp"
android:textAllCaps="false"
android:text="Руководство" />
<Button
android:id="#+id/btnPolitika"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/about_btn"
android:onClick="aboutPolitika"
android:textSize="15sp"
android:textAllCaps="false"
android:text="Политика" />
<Button
android:id="#+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/about_btn"
android:onClick="aboutYstav"
android:textSize="15sp"
android:textAllCaps="false"
android:text="Устав" />
</LinearLayout>
</HorizontalScrollView>
<FrameLayout
android:id="#+id/aboutFL"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

Related

How to set guidelines to the original screen size inside scrollview

I just started app development trying to make an e-commerce app since using fragments is a better way rather than activities I made a home page inside which I want to show first the action bar then top-selling (top-4 selling products) and after that all the products.
this is some i want to achieve
image
I am using guideline to constraint view pager to limited section but since its a fragment its not scrollable so i have to set it to scrollable but the second I set it to scroll view the size of screen increase and the view pager gets distorted.
code of my home fragment without scroll view
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
tools:context=".home.HomeFragment">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<include
android:id="#+id/home_actionbar"
layout="#layout/actionbar"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<com.google.android.material.textview.MaterialTextView
android:id="#+id/top_selling_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15sp"
android:layout_marginTop="15sp"
android:text="#string/top_selling_heading"
android:textSize="14sp"
app:fontFamily="#font/roboto_bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/home_actionbar" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.45"
app:layout_constraintTop_toBottomOf="#id/top_selling_heading" />
<androidx.viewpager.widget.ViewPager
android:id="#+id/top_seller_vp"
android:layout_width="0dp"
android:layout_height="0dp"
android:padding="5sp"
android:layout_margin="15sp"
android:clipToPadding="false"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#id/top_selling_heading"
app:layout_constraintBottom_toTopOf="#id/guideline2"
app:layout_constrainedHeight="true" />
<TextView
android:id="#+id/product_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="#id/guideline2"
app:layout_constraintStart_toStartOf="#id/top_selling_heading"
app:layout_constraintEnd_toEndOf="#id/top_selling_heading"
android:text="#string/all_products_heading"
android:textSize="20sp"
android:fontFamily="#font/roboto_bold"/>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/productRV"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:scrollbars="vertical"
app:layout_constraintTop_toBottomOf="#id/product_heading"
android:layout_margin="10sp"
tools:listitem="#layout/product_item"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
is there any other way to achieve this. please help fast..
try using LinearLayout inside scrollView(Copy and paste)
<FrameLayout 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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="#+id/home_actionbar"
layout="#layout/actionbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/top_selling_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15sp"
android:layout_marginTop="15sp"
android:text="#string/top_selling_heading"
android:textSize="14sp"
app:fontFamily="#font/roboto_bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/home_actionbar" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.45"
app:layout_constraintTop_toBottomOf="#id/top_selling_heading" />
<androidx.viewpager.widget.ViewPager
android:id="#+id/top_seller_vp"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="15sp"
android:clipToPadding="false"
android:padding="5sp"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toTopOf="#id/guideline2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/top_selling_heading" />
<TextView
android:id="#+id/product_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/roboto_bold"
android:text="#string/all_products_heading"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="#id/top_selling_heading"
app:layout_constraintStart_toStartOf="#id/top_selling_heading"
app:layout_constraintTop_toBottomOf="#id/guideline2" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/productRV"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10sp"
android:scrollbars="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/product_heading"
tools:listitem="#layout/product_item" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</FrameLayout>

ScrollView does not scroll up properly when inside BottomSheet

I created a ScrollView inside a BottomSheet and yes, it scrolls down properly but when it stops and I try to scroll up, the BottomSheet instead collapses. But when I scroll down first before scrolling up, it actually scrolls up properly. I don't want my users to feel the need to scroll down first before actually scrolling up because this can cause user frustration.
Here is my xml code:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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">
<androidx.drawerlayout.widget.DrawerLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/drawer_layout"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<androidx.fragment.app.FragmentContainerView
android:id="#+id/mapsRoute"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/menu_button"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="30dp"
android:layout_marginTop="40dp"
android:onClick="ClickMenu"
android:src="#drawable/ic_baseline_menu_24"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="#000000" />
<TextView
android:layout_width="150dp"
android:layout_height="wrap_content"
android:text="TIP: To scroll back up the route viewer, swipe up first then swipe down."
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="10dp"
android:layout_marginBottom="65dp"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<RelativeLayout
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#FFFFFF"
>
<include layout="#layout/navigation_toolbar" />
</RelativeLayout>
</androidx.drawerlayout.widget.DrawerLayout>
<FrameLayout
android:id="#+id/routesContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
android:background="#drawable/bottomtoolbar"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:paddingTop="5dp"
android:paddingBottom="20dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
>
<ImageView
android:id="#+id/baselineRouteViewer"
android:layout_width="60dp"
android:layout_height="8dp"
android:src="#drawable/ic_baseline"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="15dp"
/>
<TextView
android:id="#+id/routesText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="VIEW ROUTES & TERMINALS"
android:fontFamily="#font/assistantextrabold"
android:textColor="#color/secondary"
android:textSize="25sp"
android:layout_marginTop="20dp"
android:layout_marginBottom="10dp"
app:layout_constraintTop_toBottomOf="#+id/baselineRouteViewer"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
/>
<com.google.android.material.tabs.TabLayout
android:id="#+id/routeTabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/primary"
app:tabSelectedTextColor="#color/secondary"
app:tabTextColor="#color/custom3"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#id/routesText"
app:layout_constraintRight_toRightOf="parent">
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BUS ROUTES"/>
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="JEEP ROUTES"/>
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TERMINALS"/>
</com.google.android.material.tabs.TabLayout>
<androidx.viewpager.widget.ViewPager
android:id="#+id/routeViewPager"
android:layout_width="match_parent"
android:layout_height="220dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/routeTabs"
/>
<Button
android:id="#+id/clearMap"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="Clear Map"
android:textSize="10sp"
android:fontFamily="#font/assistantextrabold"
app:layout_constraintTop_toBottomOf="#+id/routeViewPager"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="10dp"
android:layout_marginLeft="20dp"
android:backgroundTint="#color/secondary"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

How to fix some views in Relative Layout

I have implemented simple relative layout for chat inside one of fragments layout called "Chat". The problem is that when I click EditText to type message, Linear Layout for sending messages disappears and messages are superimposed on the items above(I want them no to overlay any element except recycler view).
How to fix it?
Below I put the code of layout and screenshots Layout and Layout after click
<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"
tools:context=".ChatFragment">
<Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp"
android:theme="#style/ThemeOverlay.AppCompat.Light"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/start_at_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="Start at"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</Toolbar>
<LinearLayout
android:id="#+id/chat_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/white"
android:gravity="center_horizontal"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent">
<ImageButton
android:id="#+id/attachBtn"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#null"
android:src="#drawable/ic_attach_file"
tools:ignore="SpeakableTextPresentCheck" />
<EditText
android:id="#+id/messageEt"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#null"
android:hint="Start typing..."
android:inputType="textCapSentences|textMultiLine" />
<ImageButton
android:id="#+id/send_btn"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#null"
android:src="#drawable/ic_send"
tools:ignore="SpeakableTextPresentCheck" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recycler_view_chat"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/chat_layout"
android:layout_below="#+id/toolbar"
android:background="#AEFFFFFF"
tools:listitem="#layout/message_left" />
</RelativeLayout>

custom floating action button hidden behind toolbar

I want to display a custom floating action button on top left corner of screen. There is Extended floating action button but it doesn't serve my purpose because i want a button with two images, one back icon and another activity image icon. So to achieve this look i used a custom cardview. But the problem is the button is hidden behind toolbar. How to bring it forward, i used elevation doesn't seem to be working.
<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="#dimen/height_toolbar"
android:background="#drawable/background_small"
app:popupTheme="#style/AppTheme.PopupOverlay">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/nav_button_image"
android:orientation="horizontal"
android:paddingBottom="5dp">
<!-- toolbar counter 1-->
<LinearLayout
android:id="#+id/linearLayout_app_bar_toolbar_plants"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="#id/linearLayout_app_bar_toolbar_to_do"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/plants"
android:textAllCaps="true"
android:textColor="#color/bg_color"
android:textSize="#dimen/text_size_textView_actionbar" />
<TextView
android:id="#+id/plant_count_appbar_main"
android:layout_width="wrap_content"
android:layout_height="#dimen/textView_size_actionbar"
android:layout_gravity="center"
android:text="0/0"
android:textAlignment="center"
android:textColor="#color/bg_color"
android:textSize="#dimen/text_size_textView_actionbar"
android:textStyle="bold" />
</LinearLayout>
<!-- toolbar counter 2-->
<LinearLayout
android:id="#+id/linearLayout_app_bar_toolbar_to_do"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#id/linearLayout_app_bar_toolbar_warnings"
app:layout_constraintStart_toEndOf="#id/linearLayout_app_bar_toolbar_plants"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/to_do"
android:textAllCaps="true"
android:textColor="#color/bg_color"
android:textSize="#dimen/text_size_textView_actionbar" />
<TextView
android:id="#+id/todo_count_appbar_main"
android:layout_width="wrap_content"
android:layout_height="#dimen/textView_size_actionbar"
android:layout_gravity="center"
android:text="0/0"
android:textAlignment="center"
android:textColor="#color/bg_color"
android:textSize="#dimen/text_size_textView_actionbar"
android:textStyle="bold" />
</LinearLayout>
<!-- toolbar counter 3-->
<LinearLayout
android:id="#+id/linearLayout_app_bar_toolbar_warnings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#id/linearLayout_app_bar_toolbar_to_do"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/warnings"
android:textAllCaps="true"
android:textColor="#color/bg_color"
android:textSize="#dimen/text_size_textView_actionbar" />
<TextView
android:id="#+id/warning_count_appbar_main"
android:layout_width="#dimen/textView_size_actionbar"
android:layout_height="#dimen/textView_size_actionbar"
android:layout_gravity="center"
android:background="#drawable/red_circle"
android:text="0"
android:textAlignment="center"
android:textColor="#color/bg_color"
android:textSize="#dimen/text_size_textView_actionbar"
android:textStyle="bold" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="#dimen/height_imageView_actionbar_logo"
android:layout_alignParentBottom="true"
android:scaleType="fitStart"
android:src="#drawable/gardify_logo_header" />
</RelativeLayout>
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<include layout="#layout/content_main" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:layout_gravity="right"/>
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
app:cardBackgroundColor="#color/colorPrimary"
android:elevation="10dp"
android:layout_marginTop="80dp"
app:cardCornerRadius="0dp"
app:popupTheme="#style/AppTheme.AppBarOverlay"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/margin_padding_size_small"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="10dp"
android:src="#drawable/ic_back_arrow" />
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/gardify_app_icon_to_do_kalender" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Try using
app:elevation
instead of
android:elevation
Then set the elevation for cardview greater than the appbar/toolbar.
Try to move the <CardView /> element above the <AppBarLayout /> element

ANDROID ConstraintLayout - how to make a view stetch to the entire width and height of remainder of screen?

hey can someone paste this code and tell me why i am not able to stretch the pink textview to fill the remainder of the empty screen.
Here is my code using constraintLayout primarily:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#android:color/white"
android:elevation="4dp">
<TextView
android:id="#+id/toolbar_title"
fontPath="fonts/Medium-Extd.otf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/check_out"
android:textAllCaps="true"
android:textColor="#000000"
android:textSize="14sp"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/nsv_checkout_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/footer"
android:background="#dadbdd"
android:fillViewport="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp">
<android.support.v7.widget.CardView
android:id="#+id/cvOne"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:elevation="4dp">
<ViewFlipper
android:id="#+id/switcher"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:measureAllChildren="false">
<android.support.constraint.ConstraintLayout
android:id="#+id/clPaymentSuccessful"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="25dp"
android:layout_marginTop="30dp"
>
<ImageView
android:id="#+id/iv"
android:layout_width="20dp"
android:layout_height="26dp"
android:src="#drawable/bag_icon_heart"
app:layout_constraintBottom_toTopOf="tvStatus"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<TextView
android:id="#+id/tvStatus"
fontPath="fonts/Medium-Extd.otf"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textAlignment="center"
android:textSize="18sp"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintTop_toBottomOf="#id/iv"
tools:text="Payment Successful"/>
<TextView
android:id="#+id/tvAmount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:textAlignment="center"
android:textSize="18sp"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintTop_toBottomOf="#id/tvStatus"
tools:text="$3,800 USD"/>
<TextView
android:id="#+id/tvOrderNum"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:textAlignment="center"
android:textSize="18sp"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintTop_toBottomOf="#id/tvAmount"
tools:text="your order is 7900434343"/>
</android.support.constraint.ConstraintLayout>
</ViewFlipper>
</android.support.v7.widget.CardView>
<ViewFlipper
android:id="#+id/switcher_cta"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#color/watermelon"
android:measureAllChildren="false"
app:layout_constraintBottom_toTopOf="#+id/btn_close_cta"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/cvOne">
<android.support.constraint.ConstraintLayout
android:id="#+id/clcta"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/tvShowStaffCta"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:textAlignment="center"
android:textSize="18sp"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintTop_toTopOf="parent"
tools:text="Show this screen to Store Staff to complete your purchase"/>
</android.support.constraint.ConstraintLayout>
</ViewFlipper>
<android.support.v7.widget.AppCompatButton
android:id="#+id/btn_close_cta"
fontPath="fonts/Medium-Extd.otf"
android:layout_width="match_parent"
android:layout_height="41dp"
android:background="#color/action_blue"
android:clickable="true"
android:elevation="4dp"
android:gravity="center"
android:text="#string/close"
android:textAlignment="center"
android:textColor="#ffffff"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"/>
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
there is a viewflipper called switcher_cta i just want that to take up the remainder grey area of the screen. how can i stetch it ?
You have correctly set constraints to top and bottom, but in order for them to work the View's height must be set to 0dp.
Also avoid setting match parent in ConstraintLayout , since your view is aligned left and right to parent, setting width to 0dp will fill up the space.
<ViewFlipper
android:id="#+id/switcher_cta"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="10dp"
android:background="#color/watermelon"
android:measureAllChildren="false"
app:layout_constraintBottom_toTopOf="#+id/btn_close_cta"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/cvOne">

Categories

Resources