我想从这里创建一个带有滑动(正面和背景)的listView:
https://github.com/47deg/android-swipelistview
https://github.com/47deg/android-swipelistview-sample/
我创建了一个定义行元素的 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/front"
android:tag="front"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#ffffff">
<ImageView
android:id="@+id/ImageView01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<TextView
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/ImageView01"
android:layout_centerHorizontal="true"
android:textSize="18sp"
android:textStyle="bold"
android:inputType="textMultiLine" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/back"
android:background="#e3e3e3"
android:tag="back"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
>
<Button
android:id="@+id/deleteBtn1"
android:layout_width="150dp"
android:layout_height="100dp"
android:text="Delete" />
<Button
android:id="@+id/UpdateBtn1"
android:layout_width="150dp"
android:layout_height="100dp"
android:text="Update" />
</LinearLayout>
</FrameLayout>
和 ListView xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/linearLayout1"
android:orientation="vertical" >
<EditText android:id="@+id/EditText01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:hint="Search">
</EditText>
<com.fortysevendeg.android.swipelistview.SwipeListView
xmlns:swipe="http://schemas.android.com/apk/res-auto"
android:id="@+id/example_lv_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@drawable/profile_listview_back"
android:listSelector="#00000000"
swipe:swipeActionLeft="dismiss"
swipe:swipeActionRight="reveal"
swipe:swipeBackView="@+id/back"
swipe:swipeCloseAllItemsWhenMoveList="true"
swipe:swipeFrontView="@+id/front"
swipe:swipeMode="both" />
</LinearLayout>
但是,当我运行这个 ListView 时,它会向我显示前面的背景(我希望只有当我滑动前面时,它才会向我显示后面)
我希望删除和更新按钮仅在向前滑动时才会显示..
我该如何解决这个问题?非常感谢
最佳答案
在你的行布局中,你应该在RelativeLayout之前有LinearLayout
元素的顺序很重要
<LinearLayout>
.... buttons ....
</LinearLayout>
<RelativeLayout>
.... image and text ....
</RelativeLayout>
关于java - Xml 文件图像覆盖图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15551675/