在没有白色背景的android studio中显示imageview [英] show imageview in android studio without white background

查看:91
本文介绍了在没有白色背景的android studio中显示imageview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个透明的图像,当我在图像视图中添加图像时,它看起来像这样
[输出图像 1 ]

I have a transparent image and when I add in my imageview it appears like this
[output image 1]

但是我想去除图像的白色.我只需要显示图像的carin并去除白色边框,使布局背景可以显示,那么我有什么办法.

but I want to remove the white color of the image .I need only the carin the image to be show and remove the white borders and make the layout background to be shown is there any way I can do it.

这是我的cardview.xml

this is my cardview.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="90dp"
android:layout_height="130dp"
android:layout_margin="5dp"
app:cardCornerRadius="8dp"
app:cardElevation="10dp"
android:id="@+id/cardview">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/category_item"
        android:layout_width="90dp"
        android:layout_height="90dp"
        android:layout_gravity="center"
         />

    <TextView
        android:id="@+id/cat_name"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="10sp"
        android:layout_gravity="center_horizontal"
        android:textColor="@color/dark_grey_two"
        android:textSize="12sp"/>


</LinearLayout>

推荐答案

为ImageView使用透明背景,如下所示:

Use transparent background for ImageView like below:

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<ImageView
    android:background="@android:color/transparent" 
    android:id="@+id/category_item"
    android:layout_width="90dp"
    android:layout_height="90dp"
    android:layout_gravity="center"
     />

<TextView
    android:id="@+id/cat_name"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="10sp"
    android:layout_gravity="center_horizontal"
    android:textColor="@color/dark_grey_two"
    android:textSize="12sp"/>

</LinearLayout>

这篇关于在没有白色背景的android studio中显示imageview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆