分享一个圆角自定义的漂亮AlertDialog.docx

上传人:b****6 文档编号:5762830 上传时间:2023-01-01 格式:DOCX 页数:21 大小:58.57KB
下载 相关 举报
分享一个圆角自定义的漂亮AlertDialog.docx_第1页
第1页 / 共21页
分享一个圆角自定义的漂亮AlertDialog.docx_第2页
第2页 / 共21页
分享一个圆角自定义的漂亮AlertDialog.docx_第3页
第3页 / 共21页
分享一个圆角自定义的漂亮AlertDialog.docx_第4页
第4页 / 共21页
分享一个圆角自定义的漂亮AlertDialog.docx_第5页
第5页 / 共21页
点击查看更多>>
下载资源
资源描述

分享一个圆角自定义的漂亮AlertDialog.docx

《分享一个圆角自定义的漂亮AlertDialog.docx》由会员分享,可在线阅读,更多相关《分享一个圆角自定义的漂亮AlertDialog.docx(21页珍藏版)》请在冰豆网上搜索。

分享一个圆角自定义的漂亮AlertDialog.docx

分享一个圆角自定义的漂亮AlertDialog

分享一个圆角自定义的漂亮AlertDialog

 

\res\drawable-hdpi\bg_title_custom_dialog.xml:

xmlversion="1.0"encoding="utf-8"?

>

android="

angle="270"android:

endColor="#e1e1e1"android:

startColor="#e1e1e1"/>

topLeftRadius="15dp"android:

topRightRadius="15dp"/>

\res\drawable-hdpi\bg_middle_custom_dialog.xml:

xmlversion="1.0"encoding="utf-8"?

>

android="

angle="270"android:

endColor="#f5f5f5"android:

startColor="#f5f5f5"/>

\res\drawable-hdpi\bg_bottom_custom_dialog.xml:

xmlversion="1.0"encoding="utf-8"?

>

android="

angle="270"android:

endColor="#e1e1e1"android:

startColor="#e1e1e1"/>

bottomLeftRadius="15dp"android:

bottomRightRadius="15dp"/>

\res\drawable-hdpi\bbuton_info_rounded.xml:

xmlversion="1.0"encoding="utf-8"?

>

android="

state_pressed="true">

color="@color/bbutton_info_pressed"/>

width="1dp"android:

color="@color/bbutton_info_edge"/>

radius="@dimen/bbuton_rounded_corner_radius"/>

state_enabled="false">

color="@color/bbutton_info_disabled"/>

width="1dp"android:

color="@color/bbutton_info_disabled_edge"/>

radius="@dimen/bbuton_rounded_corner_radius"/>

color="@color/bbutton_info"/>

width="1dp"android:

color="@color/bbutton_info_edge"/>

radius="@dimen/bbuton_rounded_corner_radius"/>

\res\drawable-hdpi\bbuton_danger_rounded.xml:

xmlversion="1.0"encoding="utf-8"?

>

android="

state_pressed="true">

color="@color/bbutton_danger_pressed"/>

width="1dp"android:

color="@color/bbutton_danger_edge"/>

radius="@dimen/bbuton_rounded_corner_radius"/>

state_enabled="false">

color="@color/bbutton_danger_disabled"/>

width="1dp"android:

color="@color/bbutton_danger_disabled_edge"/>

radius="@dimen/bbuton_rounded_corner_radius"/>

color="@color/bbutton_danger"/>

width="1dp"android:

color="@color/bbutton_danger_edge"/>

radius="@dimen/bbuton_rounded_corner_radius"/>

\res\layout\custom_dialog_layout.xml:

xmlversion="1.0"encoding="utf-8"?

>

android="

xmlns:

tools="

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

minWidth="280dip"

android:

orientation="vertical"

android:

background="@null">

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

background="@drawable/bg_title_custom_dialog"

android:

paddingTop="10dip"

android:

paddingBottom="10dip"

android:

orientation="horizontal">

android:

layout_width="32dp"

android:

layout_height="32dp"

android:

layout_gravity="center_vertical"

android:

layout_marginLeft="10dip"

android:

src="@drawable/ic_expand"

android:

contentDescription="@string/line"/>

android:

id="@+id/title"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_gravity="center_vertical"

android:

layout_marginLeft="8dip"

android:

textSize="16sp"

/>

android:

id="@+id/content"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

minHeight="100dip"

android:

background="@drawable/bg_middle_custom_dialog"

android:

orientation="vertical"

android:

gravity="center">

android:

id="@+id/message"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

layout_marginLeft="10dip"

android:

textSize="16sp"

android:

textColor="#FF000000"/>

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

paddingTop="5dip"

android:

paddingBottom="5dip"

android:

paddingLeft="5dip"

android:

paddingRight="5dip"

android:

background="@drawable/bg_bottom_custom_dialog"

android:

orientation="horizontal">

android:

id="@+id/positiveButton"

android:

layout_width="0dip"

android:

layout_height="wrap_content"

android:

background="@drawable/bbuton_info_rounded"

android:

textColor="@color/bg_white"

android:

layout_weight="1"

android:

singleLine="true"/>

android:

id="@+id/negativeButton"

android:

layout_width="0dip"

android:

layout_height="wrap_content"

android:

background="@drawable/bbuton_danger_rounded"

android:

layout_marginLeft="3dip"

android:

textColor="@color/bg_white"

android:

layout_weight="1"

android:

singleLine="true"/>

\res\layout\activity_main.xml:

android="

xmlns:

tools="

android:

layout_width="match_parent"

android:

layout_height="match_parent"

android:

paddingBottom="@dimen/activity_vertical_margin"

android:

paddingLeft="@dimen/activity_horizontal_margin"

android:

paddingRight="@dimen/activity_horizontal_margin"

android:

paddingTop="@dimen/activity_vertical_margin"

tools:

context=".MainActivity">

android:

id="@+id/textView1"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

text="@string/hello_world"/>

android:

id="@+id/button1"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_alignLeft="@+id/textView1"

android:

layout_below="@+id/textView1"

android:

layout_marginLeft="22dp"

android:

layout_marginTop="18dp"

android:

text="Button"/>

CustomDialog.java:

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

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

package com.example.test;

  

import android.app.Dialog;

import android.content.Context;

import android.content.DialogInterface;

import android.view.LayoutInflater;

import android.view.View;

import android.view.ViewGroup.LayoutParams;

import android.widget.Button;

import android.widget.LinearLayout;

import android.widget.TextView;

  

/**

 *

 *CreatecustomDialogwindowsforyourapplication

 *Customdialogsrelyoncustomlayoutswichallowyouto

 *createanduseyourownlook&feel.

 *

 *UnderGPLv3:

 http:

//www.gnu.org/licenses/gpl-3.0.html

 *

 *@authorantoinevianey

 *

 */

public class CustomDialog extends Dialog{

  

    public CustomDialog(Contextcontext, int theme){

        super(context,theme);

    }

  

    public CustomDialog(Contextcontext){

        super(context);

    }

  

    /**

     *Helperclassforcreatingacustomdialog

     */

    public static class Builder{

  

        private Contextcontext;

        private Stringtitle;

        private Stringmessage;

        private StringpositiveButtonText;

        private StringnegativeButtonText;

        private ViewcontentView;

  

        private DialogInterface.OnClickListenerpositiveButtonClickListener,negativeButtonClickListener;

  

        public Builder(Contextcontext){

            this.context=context;

        }

  

        /**

         *SettheDialogmessagefromString

         *@paramtitle

         *@return

         */

        public BuildersetMessage(Stringmessage){

            this.message=message;

            return this;

        }

  

        /**

         *SettheDialogmessagefromresource

         *@paramtitle

         *@return

         */

        public BuildersetMessage(int message){

            this.message=(String)context.getText(message);

            return this;

        }

  

        /**

         *SettheDialogtitlefromresource

         *@paramtitle

         *@return

         */

        public BuildersetTitle(int title){

            this.title=(String)context.getText(title);

            return this;

        }

  

        /**

         *SettheDialogtitlefromString

         *@paramtitle

         *@return

         */

        public BuildersetTitle(Stringtitle){

            this.title=title;

            return this;

        }

  

        /**

         *SetacustomcontentviewfortheDialog.

         *Ifamessage

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 自然科学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1