当前位置:   article > 正文

Android:使用Activity制作中间弹窗_android activity 从屏幕中间飞出

android activity 从屏幕中间飞出

使用Activity制作中间弹窗

前言

使用activity制作弹窗的好处就是,自由发挥的余地更大了。匆匆的用activity制作了中间弹窗的小demo,没有重写activity显示和消失的动画,圆角没有添加。上班太忙了,有空再补上。先看看效果图吧。希望有人能用得上。
在这里插入图片描述 在这里插入图片描述

布局文件

activity_dialog.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:orientation="vertical"
    android:padding="12dp"
    tools:context=".DialogActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/color_white"
        android:orientation="vertical"
        android:padding="10dp">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:text="对话框标题"
                android:textSize="16dp"
                android:textStyle="bold" />


            <ImageView
                android:id="@+id/close_icon"
                android:layout_width="25dp"
                android:layout_height="25dp"
                android:layout_alignParentRight="true"
                android:padding="5dp"
                android:src="@drawable/icon_close" />

        </RelativeLayout>

        <TextView
            android:id="@+id/content_view"
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:layout_marginTop="10dp"
            android:background="@color/color_light_gray"
            android:text="对话框内容"
            android:textSize="14dp" />

    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@color/color_gray" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Button
            android:id="@+id/btn_cancel"
            android:layout_width="wrap_content"
            android:layout_height="44dp"
            android:layout_weight="1"
            android:background="@color/color_white"
            android:text="取消"
            android:textColor="@color/color_gray" />

        <Button
            android:id="@+id/btn_ok"
            android:layout_width="wrap_content"
            android:layout_height="44dp"
            android:layout_weight="1"
            android:background="@color/color_orange"
            android:text="确定"
            android:textColor="@color/color_white" />

    </LinearLayout>
</LinearLayout>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81

完整代码

布局布好了,activity就好写了,无非是 中间按钮 启动弹窗activity 传递数据,弹窗 的取消和确定执行相应的逻辑并返回 上一个活动。完整代码可以下载,或者github最新代码

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/225163
推荐阅读
相关标签
  

闽ICP备14008679号