Xamarin.Android -表单透明

ef1yzkbh  于 2023-11-15  发布在  Android
关注(0)|答案(1)|浏览(108)

在Xamarin Android中,如何使表单完全透明?
在我的布局XML.

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

字符串
在我的OnCreate.

LinearLayout ll = FindViewById<Android.Widget.LinearLayout>(Resource.Id.LLBack);
ll.SetBackgroundColor (Android.Graphics.Color.Transparent);`


但不工作:(

8yparm6h

8yparm6h1#

您可以按如下方式向文件styles.xml添加样式:

<?xml version="1.0" encoding="utf-8" ?>
<resources>
      <style name="AppTheme1" parent="android:Theme.Material.Light">

                        <item name="android:windowIsTranslucent">true</item>

                        <item name="android:windowBackground">@android:color/transparent</item>

                        <item name="android:windowContentOverlay">@null</item>

                        <item name="android:windowNoTitle">true</item>

                        <item name="android:windowIsFloating">true</item>

                        <item name="android:backgroundDimEnabled">false</item>

                        <!-- Customize your theme here. -->

                        <item name="android:windowIsFloating">true</item>

                  
      </style>
</resources>

字符串
并将此风格应用于您的活动:

[Activity(Label = "@string/app_name", Exported = true,Theme = "@style/AppTheme1" )]

相关问题