Xamarin.Android 设置Activity 背景色半透明

Xamarin.Android设置Activity 页面背景色半透明,步骤如下:

1、首先再Resources-->values文件夹下创建color.xml文件;

2、在上面color.xml文件下添加:

<?xml version="1.0" encoding="utf-8"?>
<resources>    

<!--背景半透明色 -->
    <color name="translucent">#aa000000</color>


<!--背景透明色 -->

 <color name="transparent">#00000000</color>

</resources>

3、在需要背景半透明的Activity页面将背景设置为:android:background="@color/translucent"

 代码如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/transparent"  />

可以看我做的初稿截图。如果是设置透明色,将背景设置为:android:background="@color/transparent"

猜你喜欢

转载自blog.csdn.net/xuwei_net/article/details/80205638