Xamarin Android使背景透明

时间:2019-03-29 08:14:30

标签: android xamarin.android

我试图在成功完成的操作上显示png图片,我希望使背景透明化

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:background="@android:color/transparent"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:src="@drawable/successful"
        android:layout_width="250dp"
        android:layout_gravity="center"
        android:layout_height="140dp"
        android:id="@+id/imageView1" />

</LinearLayout>

活动中

Dialog alert;
alert = new Dialog(this);
alert.SetContentView(Resource.Layout.SuccessfulPopup);
alert.Show();

1 个答案:

答案 0 :(得分:0)

确保图像的背景是透明的,即,在图像查看器中打开图像时,背景应该是透明的。

如果您想要透明的背景,请使用白色/黑色的十六进制代码,并在其前添加80:

因此,如果您以XML格式执行此操作,则类似于:

   date           promotion
1  2019-01-01         0
2  2019-01-02         1
3  2019-01-03         1
4  2019-01-04         1
5  2019-01-05         0
6  2019-01-06         0
7  2019-01-07         1
8  2019-01-08         1
9  2019-01-09         1
10 2019-01-10         1

如果通过代码进行操作,它将类似于:

       promo_start    promo_end
1      2019-01-02    2019-01-04
2      2019-01-07    2019-01-10

android:background="#80000000"

更新:

这是您的XAML外观

imageView.SetBackgroundColor(Color.Parse("#80000000"));