henryblue / TvRecyclerView

A custom RecyclerView for Android TV end
Apache License 2.0
7 stars 4 forks source link

Item scaling is duplicating view on top of original one #17

Closed kagile closed 5 years ago

kagile commented 5 years ago

Please find attached screenshot. I am using Auto Coursel example. Item scaling is duplicating and not scaled proper. What I want is just scale, not duplicate.

screenshot from 2018-10-02 17-23-07

kagile commented 5 years ago
        <app.com.tvrecyclerview.TvRecyclerView
            android:id="@+id/rv_recommended_apps"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:focusScale="1.15"
            app:fastScrollEnabled="false"
            android:layout_marginTop="@dimen/dp_10"
            app:scrollMode="followScroll" />
kagile commented 5 years ago

My row XML is:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/app_card"
    android:layout_width="@dimen/dp_220"
    android:layout_height="@dimen/dp_160"
    android:clickable="true"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:orientation="vertical">

    <FrameLayout
        android:id="@+id/fl_image_background"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

        <android.support.v7.widget.AppCompatImageView
            android:id="@+id/iv_app_image"
            android:layout_width="@dimen/dp_80"
            android:layout_height="@dimen/dp_80"
            android:layout_gravity="center"
            android:scaleType="centerCrop" />
    </FrameLayout>

    <com.library.ui.widget.CustomTextView
        android:id="@+id/tv_app_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:focusable="false"
        android:clickable="false"
        android:layout_gravity="center"
        android:layout_marginTop="@dimen/dp_5"
        android:fontFamily="@font/raleway_regular"
        android:gravity="start"
        android:textColor="@color/white"
        android:textSize="@dimen/font_24" />

</LinearLayout>
kagile commented 5 years ago

So, basically without a solid background, it fails.

henryblue commented 5 years ago

This is not a bug. The amplification logic of item is to draw a layer on the original item. If the background of the item is transparent, there will be overlapping misalignment.

kagile commented 5 years ago

@henryblue Ok. Can you suggest me a quick fix? That would be helpful. Thanks.

henryblue commented 5 years ago

You can add the 'isAutoProcessFocus' attribute, for example: <app.com.tvrecyclerview.TvRecyclerView android:id="@+id/rv_recommended_apps" android:layout_width="match_parent" android:layout_height="wrap_content" app:isAutoProcessFocus="false" app:fastScrollEnabled="false" android:layout_marginTop="@dimen/dp_10" app:scrollMode="followScroll" />

Then customize a zoom out layout to wrap the item, for example: https://github.com/henryblue/TvRecyclerView/blob/master/app/src/main/java/com/app/tvrecyclerview/view/FocusRelativeLayout.java

Specific you can refer to: https://github.com/henryblue/TvRecyclerView/blob/master/app/src/main/java/com/app/tvrecyclerview/maulCarouselActivity.java