为什么这些 ImageButtons(删除和更新)重叠
Why these ImageButtons(delete and update) are overlaying
这.xml将是RecycleView列表中item的布局,但是最后两个Button是重叠的
<?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:background="#Ffffff"
android:baselineAligned="false"
android:weightSum="1">
<LinearLayout android:id="@+id/thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dip"
android:layout_alignParentLeft="true"
android:background="@drawable/favorite"
android:layout_marginRight="5dip">
<ImageButton
android:id="@+id/imageButton"
android:layout_width="25dip"
android:layout_height="25dip"
android:background="@null"
android:src="@drawable/nofavorite"/>
</LinearLayout>
<TextView
android:id="@+id/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/thumbnail"
android:layout_toRightOf="@+id/thumbnail"
android:text="Rihanna Love the way lie"
android:textColor="#040404"
android:typeface="sans"
android:textSize="15dip"
android:textStyle="bold"/>
<TextView
android:id="@+id/artist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#343434"
android:textSize="10dip"
android:layout_toRightOf="@+id/thumbnail"
android:text="Just gona stand there and ..."
android:layout_below="@+id/text_view" />
<ImageButton android:layout_width="wrap_content"
android:id="@+id/update"
android:layout_height="wrap_content"
android:src="@drawable/nofavorite"
android:background="@null"
android:layout_alignRight="@+id/artist" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:id="@+id/delete"
android:src="@drawable/favorite"
android:layout_alignRight="@+id/artist"
/>
</RelativeLayout>
它们应该在右边的尽头,最后是删除按钮和这个按钮的左边,但在屏幕的右端是更新按钮,我稍后会绑定一些东西到这个按钮
还有一个问题,我怎样才能在物品之间做一个分隔线?
谢谢=)
您的按钮需要有属性来设置它们相对于彼此的位置。目前,关于他们立场的唯一指示是:
android:layout_alignRight="@+id/artist"
这不足以放置您的组件,因为您使用的是 RelativeLayout(这很好)。我建议您使用您的可视化编辑器来调整参数 IDE。
要记住的一件事是,XML 文件中最后描述的组件应该具有相对于其他组件的位置属性。所以在你的情况下,你的删除按钮。
这是因为您在两张图片上都使用了 layout_alignRight="@+id/artist"
,这基本上将两张图片的右边缘与 ID 为艺术家的视图的右边缘对齐。要实现您想要的效果,请在删除按钮上使用 layout_alignParentRight="true"
并在更新按钮上使用 layout_toLeftOf="@+id/delete"
。对了,为什么parent上需要layout_weightSum。它仅适用于 LinearLayout。
要在项目之间创建分隔线,您可以在其中一项上使用带左(右)边框的背景,或者在它们之间放置一个视图。
这.xml将是RecycleView列表中item的布局,但是最后两个Button是重叠的
<?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:background="#Ffffff"
android:baselineAligned="false"
android:weightSum="1">
<LinearLayout android:id="@+id/thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dip"
android:layout_alignParentLeft="true"
android:background="@drawable/favorite"
android:layout_marginRight="5dip">
<ImageButton
android:id="@+id/imageButton"
android:layout_width="25dip"
android:layout_height="25dip"
android:background="@null"
android:src="@drawable/nofavorite"/>
</LinearLayout>
<TextView
android:id="@+id/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/thumbnail"
android:layout_toRightOf="@+id/thumbnail"
android:text="Rihanna Love the way lie"
android:textColor="#040404"
android:typeface="sans"
android:textSize="15dip"
android:textStyle="bold"/>
<TextView
android:id="@+id/artist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#343434"
android:textSize="10dip"
android:layout_toRightOf="@+id/thumbnail"
android:text="Just gona stand there and ..."
android:layout_below="@+id/text_view" />
<ImageButton android:layout_width="wrap_content"
android:id="@+id/update"
android:layout_height="wrap_content"
android:src="@drawable/nofavorite"
android:background="@null"
android:layout_alignRight="@+id/artist" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:id="@+id/delete"
android:src="@drawable/favorite"
android:layout_alignRight="@+id/artist"
/>
</RelativeLayout>
它们应该在右边的尽头,最后是删除按钮和这个按钮的左边,但在屏幕的右端是更新按钮,我稍后会绑定一些东西到这个按钮
还有一个问题,我怎样才能在物品之间做一个分隔线?
谢谢=)
您的按钮需要有属性来设置它们相对于彼此的位置。目前,关于他们立场的唯一指示是:
android:layout_alignRight="@+id/artist"
这不足以放置您的组件,因为您使用的是 RelativeLayout(这很好)。我建议您使用您的可视化编辑器来调整参数 IDE。
要记住的一件事是,XML 文件中最后描述的组件应该具有相对于其他组件的位置属性。所以在你的情况下,你的删除按钮。
这是因为您在两张图片上都使用了 layout_alignRight="@+id/artist"
,这基本上将两张图片的右边缘与 ID 为艺术家的视图的右边缘对齐。要实现您想要的效果,请在删除按钮上使用 layout_alignParentRight="true"
并在更新按钮上使用 layout_toLeftOf="@+id/delete"
。对了,为什么parent上需要layout_weightSum。它仅适用于 LinearLayout。
要在项目之间创建分隔线,您可以在其中一项上使用带左(右)边框的背景,或者在它们之间放置一个视图。