android自定义弹出层
来源:互联网 发布:linux gem命令 编辑:程序博客网 时间:2024/05/25 23:57
1. [代码]DialogShow.java 跳至 [1] [2] [3] [4] [全屏预览]
01
package
com.asfman;
02
03
import
android.app.Activity;
04
import
android.os.Bundle;
05
import
android.view.View;
06
import
android.widget.Button;
07
08
public
class
DialogShow
extends
Activity {
09
10
/** Called when the activity is first created. */
11
@Override
12
public
void
onCreate(Bundle savedInstanceState) {
13
super
.onCreate(savedInstanceState);
14
setContentView(R.layout.main);
15
Button btn = (Button) findViewById(R.id.button1);
16
btn.setOnClickListener(
new
Button.OnClickListener() {
17
18
@Override
19
public
void
onClick(View v) {
20
// TODO Auto-generated method stub
21
new
Tip(DialogShow.
this
).show();
22
}
23
24
});
25
}
26
}
2. [代码]Tip.java 跳至 [1] [2] [3] [4] [全屏预览]
01
package
com.asfman;
02
03
import
android.app.Dialog;
04
import
android.content.Context;
05
import
android.view.Gravity;
06
import
android.view.View;
07
import
android.view.ViewGroup;
08
import
android.view.Window;
09
import
android.view.WindowManager;
10
import
android.widget.ImageView;
11
12
public
class
Tip {
13
14
private
ImageView image;
15
private
Dialog mDialog;
16
17
public
Tip(Context context) {
18
mDialog =
new
Dialog(context, R.style.dialog);
19
Window window = mDialog.getWindow();
20
WindowManager.LayoutParams wl = window.getAttributes();
21
wl.x = -
30
;
22
wl.y =
20
;
23
window.setAttributes(wl);
24
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
25
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
26
//window.setGravity(Gravity.CENTER);
27
window.setLayout(ViewGroup.LayoutParams.FILL_PARENT,
28
ViewGroup.LayoutParams.WRAP_CONTENT);
29
mDialog.setContentView(R.layout.tip);
30
mDialog.setFeatureDrawableAlpha(Window.FEATURE_OPTIONS_PANEL,
0
);
31
image = (ImageView) mDialog.findViewById(R.id.image);
32
image.setOnClickListener(
new
ImageView.OnClickListener() {
33
@Override
34
public
void
onClick(View arg0) {
35
mDialog.dismiss();
36
}
37
});
38
}
39
40
public
void
show() {
41
mDialog.show();
42
}
43
44
}
3. [代码]dialog.xml 跳至 [1] [2] [3] [4] [全屏预览]
01
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
02
<
resources
>
03
<
style
name
=
"dialog"
parent
=
"@android:style/Theme.Dialog"
>
04
<!-- <item name="android:windowFrame">@null</item> -->
05
<!-- <item name="android:windowIsFloating">true</item> -->
06
<!-- <item name="android:windowIsTranslucent">false</item> -->
07
<
item
name
=
"android:windowNoTitle"
>true</
item
>
08
<
item
name
=
"android:windowBackground"
>@null</
item
>
09
<!-- <item name="android:backgroundDimEnabled">false</item> -->
10
</
style
>
11
</
resources
>
4. [代码]tip.xml 跳至 [1] [2] [3] [4] [全屏预览]
01
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
02
<
LinearLayout
xmlns:android
=
"http://schemas.android.com/apk/res/android"
03
android:layout_width
=
"300dp"
android:layout_height
=
"190dp"
04
android:orientation
=
"vertical"
android:background
=
"@drawable/blueinfowindow"
>
05
<
LinearLayout
android:layout_width
=
"fill_parent"
06
android:layout_height
=
"wrap_content"
android:orientation
=
"horizontal"
07
android:id
=
"@+id/upContent"
android:layout_marginTop
=
"30dp"
08
android:layout_marginLeft
=
"30dp"
>
09
<
TextView
android:id
=
"@+id/description"
android:layout_width
=
"220dp"
10
android:layout_height
=
"wrap_content"
11
android:text="1.this is the test text!\n
12
1.this is the test text!\n1.this is the test text!\n1.this is the test text!\n"
android:textColor
=
"#000000"
/>
13
<
ImageView
android:id
=
"@+id/image"
android:background
=
"@drawable/icon"
android:layout_width
=
"wrap_content"
android:layout_height
=
"wrap_content"
/>
14
</
LinearLayout
>
15
</
LinearLayout
>
- android自定义弹出层
- android自定义弹出层
- android Dialog 自定义弹出层
- Android PopupWindow 实现自定义弹出层
- 自定义弹出层
- Android 自定义Dialog (弹出发表情层选择)
- 自定义bootstrap 弹出层 插件
- 微信小程序:自定义弹出层
- android 弹出层,窗口
- android 弹出层
- android 弹出层 示例代码
- Android弹出自定义对话框
- Android自定义弹出框
- Android 自定义弹出框
- android 自定义弹出窗口
- android自定义弹出菜单
- jquery 弹出自定义层(一)
- jquery 弹出自定义层(二)
- QT QString与char *之间的转换 .
- Android 自定义主题和风格
- Cloudera Development Kit(CDK) 简介
- hdu1695 容斥原理
- Android 自定义控件外观
- android自定义弹出层
- 翻译GoAsm官方帮助之第一篇 如何定义一个Section
- “#if 0/#if 1 ... #endif”的作用
- 中文编程软件-习语言2013版 发布啦
- App.Config详解
- android.mk
- Android自定义控件实现环形播放进度条
- 图像处理常用算法(C/C++)
- Android自定义进度条颜色