如何用图标填充整个ImageView?

时间:2015-02-27 16:34:52

标签: android android-layout android-imageview android-relativelayout

我在ImageView中有一个RelativeLayout。问题是我的图标没有填满ImageView中的所有空格。它从所有方向内部填充。我找到了一些解决方案并尝试了所有可能的组合,但它没有改变一点。我的图标规则256*256

<?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="#000000"
    android:weightSum="1">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="109dp"
        android:gravity="center"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true">

        <ImageView
            android:adjustViewBounds="true"
            android:scaleType="fitXY"
            android:background="@drawable/iconforalbumgrid"
            android:id="@+id/albumCover"
            android:layout_gravity="left"
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:layout_centerVertical="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true" />

        <TextView
            android:singleLine="true"
            android:id="@+id/albumName"
            android:layout_gravity="center"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="20dp"
            android:text="TextView"
            android:textColor="#ffffff"
            android:layout_alignTop="@+id/albumCover"
            android:layout_toRightOf="@+id/albumCover"
            android:layout_toEndOf="@+id/albumCover" />

        <TextView
            android:singleLine="true"
            android:paddingTop="10dp"
            android:textColor="#ffffff"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="Medium Text"
            android:id="@+id/textView55"
            android:layout_below="@+id/albumName"
            android:layout_toRightOf="@+id/albumCover"
            android:layout_toEndOf="@+id/albumCover" />

        <TextView
            android:singleLine="true"
            android:textColor="#ffffff"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:text="Small Text"
            android:id="@+id/textView56"
            android:layout_alignBottom="@+id/albumCover"
            android:layout_toRightOf="@+id/albumCover"
            android:layout_toEndOf="@+id/albumCover" />


    </RelativeLayout>


</RelativeLayout>

enter image description here

2 个答案:

答案 0 :(得分:2)

我认为你在图像周围有透明区域。  您必须使用没有透明区域的更新图像

答案 1 :(得分:1)

在ImageView中添加以下内容:

android:scaleType="fitXY"
相关问题