DiagonalLayout icon indicating copy to clipboard operation
DiagonalLayout copied to clipboard

Angle value changes in RecyclerView

Open NayMak opened this issue 5 years ago • 0 comments

In my RecyclerView, every item uses this XML:

<?xml version="1.0" encoding="utf-8"?>
<com.github.florent37.diagonallayout.DiagonalLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/diagonal_container_left"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:diagonal_direction="right"
    app:diagonal_position="left">

    <com.github.florent37.diagonallayout.DiagonalLayout
        android:id="@+id/diagonal_container_right"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:diagonal_direction="right"
        app:diagonal_position="right">

        <ImageView
            android:id="@+id/img"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:adjustViewBounds="true"
            app:type="image" />

    </com.github.florent37.diagonallayout.DiagonalLayout>
</com.github.florent37.diagonallayout.DiagonalLayout>

I set DiagonalLayout angles simply like that in my Adapter (according to the item's position):

if (getAdapterPosition() == 0) {
        diagonalContainerRight.setAngle(10);
} else if (getAdapterPosition() == getItemCount() - 1) {
        diagonalContainerLeft.setAngle(10);
} else {
        diagonalContainerLeft.setAngle(10);
        diagonalContainerRight.setAngle(10);
}

And here is the result:

screenshot_1538731876

Everything on this screenshot is 10 degrees rotated.

However, as you can see, there is a problem that happens only when I use DiagonalLayout in RecyclerView items : angles are not equals.

Images and both red and green rectangles should all be parallels, but it seems that DiagonalLayout angle changes when it is used in a list.

Is there a way to resolve this problem?

NayMak avatar Oct 05 '18 10:10 NayMak