以方块形式显示的drawable

时间:2018-03-08 17:41:43

标签: android android-studio drawable

drawables 资源文件夹中的一些 pngs jpegs 文件已显示为单色"块& #34;代表png / jpg应占用的一般区域。
我附上了recyclerview中应该是下载按钮的图像,以及中英国国旗。材料图标" ic_file_download ..."是变成白色斑点的那个。

旗帜" english.png"和" chinese.jpg"是那些变成彩色blob的人,虽然他们在android studio中打开文件时显然不是我能看到的。     有谁知道这里发生了什么?

我的代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:style="http://schemas.android.com/apk/res-auto"
    android:orientation="horizontal"
    android:background="@color/colorPrimary"
    android:padding="20dp">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        style="@style/busRouteTextStyle"
        android:id="@+id/bus_route"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="end"
        android:layout_weight="1"
        android:id="@+id/downloaded_count"/>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="end"
        android:text="/"
        android:id="@+id/slashie"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="end"
        android:id="@+id/firebase_count"/>

    <ImageButton
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:gravity="end"
        android:visibility="gone"
        android:layout_gravity="end"
        android:src="@drawable/ic_file_download_white_24dp"
        android:id="@+id/download_button"/>
</LinearLayout>

Android Studio Android Studio

下载手机上显示的图标 Download Icon as seen on phone

手机上看到的标志 Flags as seen on phone

1 个答案:

答案 0 :(得分:0)

这里的问题是你的图像比你的ImageButton大,你并没有告诉Android对你的图像进行任何缩放。尝试将ImageButton xml更改为:

<ImageButton
    android:layout_width="20dp"
    android:layout_height="20dp"
    android:gravity="end"
    android:visibility="gone"
    android:layout_gravity="end"
    android:src="@drawable/ic_file_download_white_24dp"
    android:id="@+id/download_button"
    android:adjustViewBounds="true"
    android:scaleType="fitCenter"/>