java - Xml 文件图像覆盖图像

标签 java android

我想从这里创建一个带有滑动(正面和背景)的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 时,它会向我显示前面的背景(我希望只有当我滑动前面时,它才会向我显示后面)

我希望删除和更新按钮仅在向前滑动时才会显示..

我该如何解决这个问题?非常感谢

enter image description here

最佳答案

在你的行布局中,你应该在RelativeLayout之前有LinearLayout

元素的顺序很重要

<LinearLayout>

  .... buttons ....

</LinearLayout>

<RelativeLayout>

  .... image and text ....

</RelativeLayout>

关于java - Xml 文件图像覆盖图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15551675/

相关文章:

android - 如何更改底部导航上的非 Activity 颜色?

android - 通过基础设施 WiFi 或对等 Wifi 网络将音频从 iPhone 实时流式传输到 Android

java - Android 谷歌地图标记移动问题

java - Android 表单作为 Activity

android - 顶级命令 Android 8

java - 使用 wait/notify 顺序执行线程

java - 在 Java 中哈希 double

java - 无法使用 java(1-1-2100) 从新年日期减去 1 天

Java 内存泄漏 - jmap 不显示类,但 jstat 显示

java - 如何在不指定 servlet 位置的情况下谎报错误代码?