对话框活动-自定义主题

时间:2018-06-24 10:58:40

标签: android xamarin

我一直在尝试在活动对话框中实现自定义主题,目标是实现以下目标

enter image description here

在关闭活动之前,我显示Progressbar 15秒钟,我的活动对话框如下所示

enter image description here

尽管它正在做应做的事情,但我仍然没有得到以下结果

  

1。。背景是“ 透明”,我希望它像第一个屏幕截图一样完全透明

     

2。。我将该活动设置为ExcludeFromRecents = true,但在那15秒内它仍显示在最近的应用程序列表中

现在输入代码

  

我的对话框布局如下-DialogActivityLayout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_gravity="bottom|center" 
    android:gravity="bottom"
    android:orientation="vertical" >
  <ProgressBar
        android:id="@+id/progressRecicer"
        style="?android:attr/progressBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"       
         android:layout_gravity="bottom|center"
        android:gravity="bottom"/>   
</RelativeLayout>
  

我的对话框主题样式如下styles.xml

<style name="AppCompatDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>   
  </style>
  

我的活动代码如下

[Activity(Label = "Dialog Activity", MainLauncher = false, Theme = "@style/AppCompatDialogTheme", ExcludeFromRecents = true)]

我的“活动OnCreate(Bundle savedInstanceState)”方法如下

base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.DialogActivityLayout);
Window.SetBackgroundDrawable(new ColorDrawable(Android.Graphics.Color.Transparent));
this.SetFinishOnTouchOutside(false);
this.SetTheme(Resource.Style.AppCompatDialogTheme);
Toast.MakeText(this, "Dialog Activity Opened", ToastLength.Long).Show();
Handler h = new Handler();
Action myAction = () =>
{
  Finish();
};
h.PostDelayed(myAction, 15000);

为实现这两个目标提供的任何帮助均受到高度赞赏

1 个答案:

答案 0 :(得分:1)

要减少调光量,您必须使用以下方法:

s/alt

因此您只需要将其设置为0。

希望这会有所帮助。