家庭記賬本APP目前實現了記賬功能,也就是說增加功能,今天打算添加刪除功能,參考着增加的代碼研究,從網上查閱資料,打算實現左滑刪除功能,目前學到了xml里面的HorizontalScrollView布局,可以將刪除按鈕隱藏在最右側,左滑可以將其顯現出來
<?xml version="1.0" encoding="utf-8"?> <HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="80dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:id="@+id/tv_title" android:layout_width="150dp" android:layout_height="80dp" android:layout_alignParentLeft="true" android:layout_marginLeft="10dp" android:ellipsize="marquee" android:gravity="center" android:singleLine="true" android:text="costTitle" android:textSize="35sp" /> <TextView android:id="@+id/tv_date" android:layout_width="100dp" android:layout_height="80dp" android:layout_marginLeft="15dp" android:layout_toRightOf="@+id/tv_title" android:gravity="center" android:text="costDate" android:textSize="20sp" /> <TextView android:id="@+id/tv_cost" android:layout_width="100dp" android:layout_height="80dp" android:layout_alignParentRight="true" android:layout_marginRight="20dp" android:gravity="center" android:text="30" android:textSize="30sp" /> <TextView android:id="@+id/tv_delete" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="delete"/> </LinearLayout> </HorizontalScrollView>
但這僅僅是前端顯示了出來,刪除功能的實現還是不行。
