Android : Animate List Item content on long press listView

on Tuesday, September 9, 2014


I have a fragment with ListView. I want to implement standard android behavior - short click on list item - segue to next screen, on long press, otherwise - edit mode. I've managed to intercept long press event. From default state :


enter image description here


I want animatedly move picture and text right:


enter image description here


My list view item have the following layout :



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:orientation="horizontal"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingBottom="8dp"
android:paddingTop="8dp">

<TextView
android:id="@+id/items_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="0dip"
android:layout_alignParentRight="true"
android:gravity="center"
android:textColor="@android:color/darker_gray"
android:layout_centerVertical="true"
android:textSize="20sp" >
</TextView>

<TextView
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="4dp"
android:textColor="@android:color/black"
android:textSize="20sp"
android:gravity="center_vertical|left"
android:layout_alignBottom="@+id/items_count"
android:layout_toRightOf="@+id/imageView"
android:layout_toEndOf="@+id/imageView"
android:layout_centerVertical="true"
android:layout_marginLeft="8dp">
</TextView>

<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:id="@+id/imageView"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>


How can i achieve this? Thanks in advance.


0 comments:

Post a Comment