背景颜色不同于listview和textview与边距

时间:2014-01-10 18:40:02

标签: android listview textview

我设置了这种颜色:

<color name="lightgrey">#1a000000</color>

并将此layouttextview作为边距,并listview

正如您在下图所示,texviewlistview

的背景颜色略有不同

enter image description here

为什么会这样?

这是我的布局:

<?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:background="@color/lightgrey"
              android:orientation="vertical"
        >

    <TextView
            android:id="@+id/queryTitle"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10sp"
            android:background="@drawable/rect"
            android:clickable="false"
            android:gravity="center"
            android:minHeight="50dp"
            android:textColor="#000000"
            android:textSize="30sp"
            android:textStyle="bold"
            android:typeface="normal"
            />

    <ListView
            android:id="@android:id/list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clickable="false"
            android:divider="@null"
            android:fastScrollEnabled="true"
            android:textFilterEnabled="true"/>

</LinearLayout>

@drawable/rect

<shape xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="rectangle">

<solid android:color="@color/white"/>

<corners
        android:bottomLeftRadius="5dip"
        android:bottomRightRadius="5dip"
        android:topLeftRadius="5dip"
        android:topRightRadius="5dip"/>

2 个答案:

答案 0 :(得分:1)

检查用于列表项的布局,也许您使用不同的背景颜色作为主布局的背景。

...并且记住在ListView标签上始终添加下一个属性,以避免在滚动列表时出现黑色背景。

android:cacheColorHint="#00000000" // setting transparent color

答案 1 :(得分:1)

将背景颜色更改为正确的格式,如#e3e3e3(最多6个字符),因为android可能会忽略其余的字符。将背景颜色更改为最多6个字符颜色集,看看它是否有效。

相关问题