如何在 Android 中删除 LinearLayout 边框
How to remove LinearLayout border in Android
我有一个 LinearLayout,它重复适配器中定义的元素。我一直试图删除底部边框,但没有成功。
res/drawable/rev_no_border.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="-1dp"
android:left="-1dp"
android:right="-1dp"
android:top="-1dp">
<shape android:shape="rectangle" />
</item>
<item
android:bottom="-1dp"
android:left="-1dp"
android:right="-1dp"
android:top="-1dp">
<shape android:shape="rectangle" />
</item>
<item
android:bottom="-1dp"
android:left="-1dp"
android:right="-1dp"
android:top="-1dp">
<shape android:shape="rectangle" />
</item>
<item
android:bottom="-1dp"
android:left="-1dp"
android:right="-1dp"
android:top="-1dp">
<shape android:shape="rectangle" />
</item>
</layer-list>
这就是我将可绘制对象附加到布局的方式:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/revObjectListingWrapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="@drawable/rev_no_border"
android:color="@android:color/transparent" />
我没有做什么?
Vielen dank im voraus。
更新
线性布局默认不加边框,如果需要加边框可以使用drawable.xml文件,但布局中不需要加边框,不需要加任何东西.正常布局xml是
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
ListView 和 RecyclerView(我不知道你用的是哪一个)都可以有分隔线。基本上是在每个元素之间插入一个小视图。
对于ListView,你可以这样使用:
android:divider="@null"
android:dividerHeight="0dp"
RecyclerView 有点棘手,但您可以 google 'android recyclerview remove divider",然后有很多关于它的帖子。
android:divider="@null"
android:dividerHeight="0dp"
android:childDivider="@null"
您可以在 ExanpandleListview 中使用来删除布局中的边框。
我有一个 LinearLayout,它重复适配器中定义的元素。我一直试图删除底部边框,但没有成功。
res/drawable/rev_no_border.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="-1dp"
android:left="-1dp"
android:right="-1dp"
android:top="-1dp">
<shape android:shape="rectangle" />
</item>
<item
android:bottom="-1dp"
android:left="-1dp"
android:right="-1dp"
android:top="-1dp">
<shape android:shape="rectangle" />
</item>
<item
android:bottom="-1dp"
android:left="-1dp"
android:right="-1dp"
android:top="-1dp">
<shape android:shape="rectangle" />
</item>
<item
android:bottom="-1dp"
android:left="-1dp"
android:right="-1dp"
android:top="-1dp">
<shape android:shape="rectangle" />
</item>
</layer-list>
这就是我将可绘制对象附加到布局的方式:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/revObjectListingWrapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="@drawable/rev_no_border"
android:color="@android:color/transparent" />
我没有做什么?
Vielen dank im voraus。
更新
线性布局默认不加边框,如果需要加边框可以使用drawable.xml文件,但布局中不需要加边框,不需要加任何东西.正常布局xml是
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
ListView 和 RecyclerView(我不知道你用的是哪一个)都可以有分隔线。基本上是在每个元素之间插入一个小视图。
对于ListView,你可以这样使用:
android:divider="@null"
android:dividerHeight="0dp"
RecyclerView 有点棘手,但您可以 google 'android recyclerview remove divider",然后有很多关于它的帖子。
android:divider="@null"
android:dividerHeight="0dp"
android:childDivider="@null"
您可以在 ExanpandleListview 中使用来删除布局中的边框。