如何在列表视图中摆脱这种奇怪的白色背景

时间:2018-06-23 18:15:49

标签: android android-studio user-interface

我正在尝试制作一个iOS版本的Android应用,并且在列表视图周围和列表视图中的图像周围都出现了奇怪的白色边框,这真令人沮丧。这是屏幕截图:

screenshot

这是我的文件代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.leoconnelly.connexus.HealthCenterListActivity">

android:background="#D53D96"

<ListView
    android:id="@+id/hospitals_list_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="8dp"
    android:background="#D53D96"

    />
</RelativeLayout>

1 个答案:

答案 0 :(得分:0)

您可以从android:layout_margin="8dp"中删除ListView或将相同的背景置于父级:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#D53D96"
tools:context="com.example.leoconnelly.connexus.HealthCenterListActivity">



<ListView
    android:id="@+id/hospitals_list_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="8dp"
    android:background="#D53D96"

    />
</RelativeLayout>