使用上面的自定义图像创建android对话框片段

时间:2016-08-21 15:03:42

标签: android android-layout android-dialogfragment android-image android-dialog

1 个答案:

答案 0 :(得分:0)

您可以使用透明背景创建全屏对话框。

然后计算此循环的x / y点并放置箭头。

对话框示例:

 public void showDialog(Context context, View hourView) {
        dialog = new Dialog(context, R.style.DreamDialogStyle);
        dialog.setContentView(R.layout.dream_custom_add_photo_dialog);

   // hourView in your case will be probably view with hour timer
   // you need get for this view x and y position on your screen
   // then in your dialog layout you need setX() and setY() for your loppView
   // but your loopView will be full transparent background
   // for position of x and y on screen You can use 
   // int[] array = new int[2];
   // hourView.getLocationOnScreen(array);
   //   X =  array[0] , Y = array[1]
   // and in setX() setY() calculate loopSize for position loop on hourView
   // And for arrow would be nice if You have image with this arrow.
   // then You will need also calculate for your dilogTop and loopLeftDown
   // and setAngle() in image for fill arrow line

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
            dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }

        dialog.show();
    }

透明背景的对话框样式:

 <style name="DreamDialogStyle" parent="Theme.AppCompat.DayNight.NoActionBar">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
    </style>