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

ZoomLayout does not display the contents of the custom view #204

Closed
VahidGarousi opened this issue Jun 28, 2021 · 2 comments
Closed

ZoomLayout does not display the contents of the custom view #204

VahidGarousi opened this issue Jun 28, 2021 · 2 comments

Comments

@VahidGarousi
Copy link

VahidGarousi commented Jun 28, 2021

How can I use the custom view I made in the ZoomLayout?

Nothing is displayed when I run the application

fragment.xml

   <com.otaliastudios.zoom.ZoomLayout
        android:id="@+id/zoomLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="vertical"
        app:alignment="center"
        app:animationDuration="280"
        app:flingEnabled="true"
        app:hasClickableChildren="true"
        app:horizontalPanEnabled="false"
        app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
        app:maxZoom="2.5"
        app:maxZoomType="zoom"
        app:minZoom="0.7"
        app:minZoomType="zoom"
        app:oneFingerScrollEnabled="true"
        app:overPinchable="true"
        app:overScrollHorizontal="true"
        app:overScrollVertical="true"
        app:scrollEnabled="true"
        app:threeFingersScrollEnabled="true"
        app:transformation="centerInside"
        app:transformationGravity="auto"
        app:twoFingersScrollEnabled="true"
        app:verticalPanEnabled="true"
        app:zoomEnabled="true">

        <CruiseView
            android:id="@+id/cruiseView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    </com.otaliastudios.zoom.ZoomLayout>

CruiseView.kt


class CruiseView @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0
) : FrameLayout(context, attrs, defStyleAttr) {
    private val floors = mutableSetOf<CruiseFloorView>()
    val floorCount = 4

    private val currentFloor = 1
    private val binding = LayoutCruiseViewBinding.inflate(LayoutInflater.from(context), this, true)

    init {
        inflate(context, R.layout.layout_cruise_view, this).apply { tag = "CruiseView Main Root" }
        DataFactory.populateFloors().map {
            addFloor(it)
        }
    }

    fun addFloor(vararg floorData: CruiseFloor): CruiseView {
        floorData.forEach {
            val floor = CruiseFloorView(this.context).apply {
                initializeFloor(it)
                tag = it
            }
            floors.add(floor)
            addView(floor)
        }
        return this
    }}

layout_cruise_view.xml

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#49426C">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:tag="ConstraintLayout ImageView"
        android:layout_height="match_parent">

        <ImageView
            android:id="@+id/icBackground"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:tag="Image Container"
            android:layout_gravity="center"
            android:contentDescription="@string/img_description"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:srcCompat="@drawable/cruise_view_background" />

    </androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>

Shot:
Screenshot_1624870065

Version used

1.8.0

@VahidGarousi VahidGarousi changed the title Do not display the contents of the custom view in zoom, What should i do? ZoomLayout does not display the contents of the custom view Jun 28, 2021
@markusressel
Copy link
Collaborator

You cannot use match_parent with child views, see #54.

@stale
Copy link

stale bot commented Jul 21, 2021

This issue has been automatically marked as stale because it has not had activity in the last 20 days. It will be closed if no further activity occurs within the next seven days. Thank you for your contributions.

@stale stale bot added the status:stale label Jul 21, 2021
@stale stale bot closed this as completed Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants