3

所以我有这个

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    
    android:id="@+id/mainParent"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bgdark"
    android:orientation="vertical" 
>
    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="76dp"
        android:src="@drawable/myheader_250x60" 
    />
    <ListView
        android:id="@+id/mainListview"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </ListView>
</LinearLayout>

注意我现在已经编辑了这篇文章。我使用的是灰色背景图像,所以我认为这是在标题图像的右侧/左侧可见的内容。请参阅下面的显示问题的图像。

但是,将背景移动到列表视图并没有解决问题。因此,似乎是图像视图以某种方式具有灰色的左/右边框。由于我已将宽度设置为“match_parent”,因此它应该采用最大宽度。

在此处输入图像描述

问题是标题的顶部/右侧有一个灰色像素边框?如果可能的话,我想删除它。

4

3 回答 3

1

设置这个 scletype 属性

android:scaleType=fitXY

并像这样将图像设置为图像视图

android:background="@drawable/myheader_250x60" 
于 2013-04-10T12:10:58.183 回答
1

为您的 ImageView尝试scaleType 属性

另一种方法 - 替换

android:src="@drawable/myheader_250x60" 

为了

android:background="@drawable/myheader_250x60" 
于 2013-04-10T11:24:04.983 回答
1

尝试使用 fill_parent 而不是 match_parent 除了在 listView height 。在 listView 高度使用 wrap_content

于 2013-04-10T12:03:42.833 回答