以块形式显示的可绘制对象
drawables showing in block form
我的一些 pngs 和 jpegs 文件来自 drawables 资源文件夹显示为单色 "blocks",代表 png/jpg 应该占据的一般区域。
我在 recyclerview
中附上了应该是下载按钮的图像,以及中国和英国国旗。 material 图标 "ic_file_download..." 是变成白色斑点的图标。
标志 "english.png" 和 "chinese.jpg" 是变成彩色斑点的标志,尽管它们显然不是我在 android 工作室中打开文件时看到的那样。
有人知道这里发生了什么吗?
我的代码:
<?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工作室
下载 phone 上的图标
在 phone 上看到的标志
这里的问题是您的图片比您的 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"/>
我的一些 pngs 和 jpegs 文件来自 drawables 资源文件夹显示为单色 "blocks",代表 png/jpg 应该占据的一般区域。
我在 recyclerview
中附上了应该是下载按钮的图像,以及中国和英国国旗。 material 图标 "ic_file_download..." 是变成白色斑点的图标。
标志 "english.png" 和 "chinese.jpg" 是变成彩色斑点的标志,尽管它们显然不是我在 android 工作室中打开文件时看到的那样。 有人知道这里发生了什么吗?
我的代码:
<?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工作室
下载 phone 上的图标
在 phone 上看到的标志
这里的问题是您的图片比您的 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"/>