The transparent image is transparent somewhere in the application and is not transparent somewhere else

假如想象 提交于 2019-12-20 04:19:03

问题


In an Android application,
I have a transparent png image which is truly transparent under the following conditions:

final ImageView btnsB = new ImageView(this);
;

RelativeLayout.LayoutParams paramsB = new RelativeLayout.LayoutParams(
        RelativeLayout.LayoutParams.WRAP_CONTENT,
        RelativeLayout.LayoutParams.WRAP_CONTENT);
paramsB.addRule(RelativeLayout.CENTER_IN_PARENT);
paramsB.addRule(RelativeLayout.ABOVE, R.id.layout1);

btnsB.setLayoutParams(paramsB);
Picasso.with(this).load(R.drawable.a11).resize(B_w, B_h).into(btnsB);

my_layout.addView(btnsB);

But when I try to use the same image somewhere else it is not transparent and the parts of the image which are supposed to be transparent are black and this is the problematic conditions (Row_2_ll_img below is the mentioned image):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/main_ll"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#ffffff"
    android:orientation="vertical"
    android:layout_margin="0dp"
    android:padding="0dp">

        <TextView
            android:id="@+id/Row_1_txt"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:background="@drawable/border_colors"
            android:padding="0dp"
            android:text=""
            android:textAlignment="center"
            android:gravity="center"
            android:textColor="@color/color00"
            android:layout_marginRight="5mm"
            android:layout_marginLeft="5mm"
            android:layout_marginTop="0.1mm"
            android:layout_marginBottom="0.1mm"
            android:layout_gravity="center"
            />

        <LinearLayout
            android:id="@+id/Row_2_ll"
            android:layout_height="match_parent"
            android:layout_width="wrap_content"
            android:orientation="horizontal"
            android:gravity="center">

            <TextView
                android:id="@+id/Row_2_ll_txt"
                android:layout_height="match_parent"
                android:layout_width="wrap_content"
                android:background="@drawable/border_colors"
                android:padding="0dp"
                android:text=""
                android:textAlignment="center"
                android:gravity="center"
                android:textColor="@color/color00"
                android:layout_gravity="center"
                android:layout_weight="2"
                />

            <ImageView
                android:id="@+id/Row_2_ll_img"
                android:layout_height="match_parent"
                android:layout_width="wrap_content"
                android:gravity="center"
                android:scaleType="center"
                android:layout_weight="2"
                android:background="@android:color/transparent"
            />

            <View
                android:id="@+id/Row_2_ll_view"
                android:layout_height="match_parent"
                android:layout_width="wrap_content"
                android:layout_weight="2"
                />


        </LinearLayout>

</LinearLayout>

The point is the above xml is a view which is used in a RecyclerView's item

More information:

I use interface to receive the click event from RecyclerView's item and then open the Galley and select the mentioned image and then receive the URI of the image and then :

        View v = mRecyclerView.getLayoutManager().findViewByPosition(10);
        ImageView mImageView = (ImageView)v.findViewById(R.id.Row_2_ll_img);
        Picasso.with(this).load(Uri_M4_ViewPager_MagnifierIcon).placeholder(R.drawable.ic_launcher).resize(Dimension_x_6mm, Dimension_x_6mm).into(mImageView); 

Image:

Edit: Glide and Picasso has the same problem.

来源:https://stackoverflow.com/questions/59299095/the-transparent-image-is-transparent-somewhere-in-the-application-and-is-not-tra

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!