How To Create Leaning List Items
Solution 1:
I suggest you to use Squint
Create an layout xml with the below code. This layout file renders a single row in recycler view by displaying image and text.
<?xml version="1.0" encoding="utf-8"?><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:squint="http://schemas.android.com/apk/res-auto"android:orientation="vertical"android:layout_marginLeft="-25dp"android:layout_width="wrap_content"android:layout_height="wrap_content"><com.intrusoft.squint.DiagonalViewandroid:id="@+id/diagonalView"android:layout_width="150dp"android:layout_height="150dp"android:layout_alignParentTop="true"android:layout_centerHorizontal="true"android:scaleType="centerCrop"squint:angle="10"squint:diagonalDirection="bottom_to_top"squint:gravity="right"/><TextViewandroid:background="#80000000"android:layout_width="150dp"android:layout_height="30dp"android:gravity="center"android:textColor="#FFF"android:id="@+id/txtName"android:layout_alignBottom="@+id/diagonalView"android:layout_alignLeft="@+id/diagonalView"android:layout_alignStart="@+id/diagonalView"/></RelativeLayout>
After writing custom adapter, you should prepare the RecyclerView as follows.
LinearLayoutManagerlayoutManager=newLinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); // make it horizontal
recyclerView.setLayoutManager(layoutManager);
After applying these operations successfully, I got an image like this.
This solution may not be the perfect solution. There are some defective spots such as android:layout_marginLeft="-25dp". At least it can give you an idea.
Solution 2:
I don't know the exact answer for your problem but i would recommend to create your own DividerItemDecoration.
For more info check this: https://developer.android.com/reference/android/support/v7/widget/DividerItemDecoration.html
Solution 3:
Looks like you can't really do a RecyclerView
, since those views can't overlap. At this point, you may want to consider extending a horizontal ScrollView
, and stitch your images and other elements into one long view that you scroll by overriding the onDraw
method. You can handle click events in the onTouch
method override. This looks like a pretty big project thought, especially if you have a lot of images and have to manage memory.
Post a Comment for "How To Create Leaning List Items"