在Android应用程序中,
我有一个透明的png图像,它在以下情况下是真正透明的:
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);
但是,当我尝试在其他地方使用同一张图片时,该图片不是透明的,并且该图片中应该透明的部分是黑色的,这是有问题的条件( Row_2_ll_img 是上面提到的图片):
<?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>
重点是上面的xml是RecyclerView项目中使用的视图
更多信息:
我使用界面从RecyclerView的项目接收click事件,然后打开Galley并选择提到的图像,然后接收图像的URI,然后:
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);
编辑:Glide和毕加索有同样的问题。