Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hauler and ViewPager #37

Closed
DennyWeinberg opened this issue Jul 4, 2020 · 1 comment
Closed

Hauler and ViewPager #37

DennyWeinberg opened this issue Jul 4, 2020 · 1 comment

Comments

@DennyWeinberg
Copy link

DennyWeinberg commented Jul 4, 2020

I have the following layout:

<?xml version="1.0" encoding="utf-8"?>
<com.thefuntasty.hauler.HaulerView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/haulerView"
    app:dragUpEnabled="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            xmlns:tools="http://schemas.android.com/tools"
            android:fitsSystemWindows="true">

            <View
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/dismiss_click_view"
                android:background="@color/details_preview_dialog_background" />

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="0dp"
                android:layout_height="0dp"
                app:layout_constraintWidth_percent="@dimen/details_preview_width_ratio_percentage"
                app:layout_constraintHeight_percent="@dimen/details_preview_height_ratio_percentage"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                >

                <androidx.cardview.widget.CardView
                    android:id="@+id/cardView"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_margin="8dp"
                    app:cardCornerRadius="@dimen/details_preview_rounding"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    app:layout_constraintStart_toStartOf="parent" >

                    <androidx.viewpager.widget.ViewPager
                        android:id="@+id/view_pager"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" />

                </androidx.cardview.widget.CardView>

                <TextView
                    android:id="@+id/totalNumberOfPhotosTextView"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    tools:text="2/1234"
                    android:textSize="9sp"
                    android:layout_margin="-50dp"
                    android:gravity="center"
                    android:height="@dimen/badge_size"
                    android:minWidth="@dimen/badge_size"
                    android:textColor="@color/badgeTextColor"
                    android:elevation="10dp"
                    android:background="@drawable/badge_secondary"
                    app:layout_constraintTop_toTopOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    />

            </androidx.constraintlayout.widget.ConstraintLayout>

            <ProgressBar
                android:id="@+id/loadingProgressBar"
                style="@style/Widget.AppCompat.ProgressBar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                android:elevation="10dp"
                />

        </androidx.constraintlayout.widget.ConstraintLayout>

    </androidx.core.widget.NestedScrollView>

</com.thefuntasty.hauler.HaulerView>

So a HaulerView with it's NestedScrollView, which contaisn a ViewPager.
It works, but the ViewPager needs to be scrolled exactly in a horizontal way in order to swipe to the next item, otherwise the HaulerView takes the wipe moved a bit up/down.
it there a way of defining the angle or a treshold or something to make the horizontal scroll prior to the vertical scroll, depending on the angle or something?

EDIT: With a maps fragment inside, I can't scroll the map anymore.

@viettranhoang
Copy link

I solved this by remove NestedScrollView in avtivity layout and add NestedScrollView into fragment of viewpager.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants