`

自定义无标题Dialog

阅读更多
1.主Activity:
 
public class DialogShow extends Activity {

	private OnClickListener btnListener;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		Button btn = (Button) findViewById(R.id.Button01);
		btnListener = new View.OnClickListener() {
			public void onClick(View view) {
				new Tip(DialogShow.this).show();
			}
		};
		btn.setOnClickListener(btnListener);
	}
}
  


2.Tip.java:
public class Tip {

	private ImageView image;
	private Dialog mDialog;

	public Tip(Context context) {
		mDialog = new Dialog(context, R.style.dialog);
		Window window = mDialog.getWindow();
		WindowManager.LayoutParams wl = window.getAttributes();
		wl.x = 30;
		wl.y = 20;
		window.setAttributes(wl);
		window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
		// window.setGravity(Gravity.BOTTOM|Gravity.FILL_HORIZONTAL);
		window.setLayout(ViewGroup.LayoutParams.FILL_PARENT,
				ViewGroup.LayoutParams.WRAP_CONTENT);
		mDialog.setContentView(R.layout.tip);
		mDialog.setFeatureDrawableAlpha(Window.FEATURE_OPTIONS_PANEL, 0);
		image = (ImageView) mDialog.findViewById(R.id.image);
		image.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				mDialog.dismiss();
			}
		});
	}
	
	public void show(){
		mDialog.show();
	}

}


3.styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
	<style name="dialog" parent="@android:style/Theme.Dialog">
		<item name="android:windowFrame">@null</item>
		<item name="android:windowIsFloating">true</item>
		<item name="android:windowIsTranslucent">false</item>
		<item name="android:windowNoTitle">true</item>
		<item name="android:windowBackground">@null</item>
		<item name="android:backgroundDimEnabled">false</item>
	</style>
</resources>


4.tip.xml:
 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:layout_width="300dp" android:layout_height="190dp"
	android:orientation="vertical" android:background="@drawable/belle_frame">


	<LinearLayout android:layout_width="fill_parent"
		android:layout_height="wrap_content" android:orientation="horizontal"
		android:id="@+id/upContent" android:layout_marginTop="10dp"
		android:layout_marginLeft="3dp">
		<ImageView android:id="@+id/image" android:layout_width="80dp"
			android:layout_height="120dp" />
		<TextView android:id="@+id/description" android:layout_width="220dp"
			android:layout_height="wrap_content"
			android:text="1.this is the test text!\n
			1.this is the test text!\n1.this is the test text!\n1.this is the test text!\n
			1.this is the test text!\n1.this is the test text!\n1.this is the test text!\n" />
	</LinearLayout>
</LinearLayout>
 

分享到:
评论

相关推荐

    自定义dialog位置

    自定义Dialog 模拟popupwindow功能,随意改变Dialog位置。可以简单设置Dialog位于某个控件的上方、下方、左边、右边。

    自定义对话框(Dialog)效果

    自定义对话框(Dialog)效果,Dialog中里面放的ViewPager用来展示图片,Dialog中里面放的ViewPager用来展示图片,底部带圆点,可以设置是否自动滚动,自定义了Dialog的style,去除了背景黑色和边框,效果还不错,分享...

    Android自定义Dialog弹窗提示

    Android开发自定义的Dialog弹窗提示,ke自定义样式、标题、内容......

    HerilyAlertDialog完全自定义的Dialog源码

    HerilyAlertDialog完全自定义的Dialog源码,是一个很不错的Android标题栏源码,有兴趣的伙伴们抽时间可以看一下把。

    创建自定义对话框dialog,弹出模式窗口

    创建自定义对话框dialog,弹出模式窗口 用于创建自定义对话框的轻量级(约 4.5 KB)代码库。四种对话框可用: alerts(出错), warnings(警告), prompts(提示), success(成功)。利用一个简单的函数,你可以自定义对话框...

    Dialog 自定义系统自带

    在系统自带的Dialog的基础上,对样式进行修改.如圆角,去边框,去标题,该提示内容等.看了这个demo后,你应该就可以根据自己的需要去做出相应的Dialog.

    自定义Dialog弹窗

    从底部弹出的dialog。位置你可以在base里自己改。使用方法都有。public class BaseDialog extends Dialog { private View mContentView; public Context mContext; public LayoutInflater mInflater; public ...

    自定义动画Dialog

    该示例demo实现了自定义dialog,弹出及消失方式为自定义动画,效果非常炫,dialog上的标题,内容,按钮事件均为自定义,非常灵活,注释齐全,既适合新手学习,也可以改改就能用到实际项目中

    仿IOS的自定义组合GroupDialog(更新版)

    这个是仿IOS的自定义组合Dialog,使用方式跟系统自带的Dialog相似,是一个AndroidStudio工程,用eclipse的可以复制一下资源。 ...5、新增标题带有图标的Dialog。 6、优化进度条倒计时使用到的线程。

    Android 自定义Dialog去除title导航栏的解决方法

    今天小编就为大家分享一篇Android 自定义Dialog去除title导航栏的解决方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

    如何更改Dialog的标题与按钮颜色详解

    本文主要给大家介绍了如何更改Dialog的标题与按钮颜色的相关内容,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍吧。 android.support.v7.app.AlertDialog 在这个类中第一行就定义了如下变量: ...

    Android自定义对话框

    在我们的日常项目中很多地方会用到对话框,但是Android系统为我们提供的对话框样子和我们精心设计的界面很不协调,在这种情况下我们想很自由的定义对话框,或者有的时候我们的对话框是一个图片,没有标题和按钮,...

    Flutter 自定义Dialog

    main.dart import 'package:flutter/material.dart'; import './components/MyDialog.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { ... //标题栏 appBar: AppBar

    自定义对话框

    提供一个自定义dialog控件,可以自定义设置样式,标题,控制功能

    微信小程序之自定义dialog组件

    由于项目开发需求,坑爹的小程序没有自定义dialog(类似饿了么组件那种)。于是百度了下思路,开发了一个。   参数: title 标题 cancelText 取消文本 (默认文本为取消) confirmText 确认文本(默认文本为确定) ...

    jQuery对话框插件dialogBox 0.0.1.rar

    jQuery对话框插件dialogBox,简单实用的jquery对话框插件,配合css3效果,视觉效果完美呈现,支持模拟confirm对话框、alert提示框等,可自定义对话框标题、内容、尺寸、效果等。

    ScrollView实现自定义RelativeLayout跟随手势上下滑动显示隐藏

    根据ScrollView的自定义实现 RelativeLayout跟随手势的上下滑动显示和隐藏顶部标题栏,话不多说 直接上代码

    jQuery自定义弹窗

    title:"Windows", //窗口标题 cancel:true, //右上角是否显示关闭图标 true:显示 false:不显示 glass:true, //是否显示一个玻璃遮罩层 true:显示 false:不显示 wclose:function(){alert("用户自定义关闭事件...

    Android代码-Android Dialog 安卓对话框

    Android Dialog 一般有五种,分别是:一般对话框,列表对话框,单选按钮对话框,多选对话框,自定义对话框。 一般对话框 AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(R.mipmap....

Global site tag (gtag.js) - Google Analytics