在广播中实现 仿照系统亮度调整的dialog(系统级别dialog,去掉标题,背景不变暗,3秒后自动退出)

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="480dp"
    android:layout_height="wrap_content" >
	
    <LinearLayout
        android:id="@+id/visible_panel"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/dialog_full_holo_dark"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >
            
            <ImageView
                android:id="@+id/bri_icon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:background="@drawable/brightness_add"
                android:layout_marginLeft="5dip"
                android:padding="16dip" />

            <SeekBar
                android:id="@+id/bri_seekbar"
                style="?android:attr/seekBarStyle"
                android:layout_width="400dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_marginLeft="-10dip"
                android:focusable="true"
                android:padding="16dip"
                android:max="20" />
            
        </LinearLayout>
    </LinearLayout>
    
</FrameLayout>
<span style="white-space:pre">		</span>/**
		 * 设置亮度dialog
		 */
		if (intent.getAction().equals("est.android.setbrightness.action")) {
			mView = inflater.inflate(R.layout.brightness_dialog, null);

			mBriIcon = (ImageView) mView.findViewById(R.id.bri_icon);
			mBriSeek = (SeekBar) mView.findViewById(R.id.bri_seekbar);

			int light = preferences.getInt("Light", 10);

			mBriSeek.setProgress(light);

			mBriSeek.requestFocus();

			mBriSeek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

				@Override
				public void onStopTrackingTouch(SeekBar seekBar) {
					// TODO Auto-generated method stub
					
				}

				@Override
				public void onStartTrackingTouch(SeekBar seekBar) {
					// TODO Auto-generated method stub

				}

				@Override
				public void onProgressChanged(SeekBar seekBar, int progress,
						boolean fromUser) {
					// TODO Auto-generated method stub
					AdjustColorCompute.USE_MAP_TABLE = true;
					mColorCompute.computeLUTData(progress,preferences.getInt("Contrast", 10));
					editor.putInt("Light", progress);
					editor.commit();
					mColorCompute.extendXRGBData();
					mColorCompute.writeToFile();
					isSlide = true;
					timer.cancel();
					timer = new Timer();
					timer.schedule(new TimerTask() {
						public void run() {
							mDialog.dismiss();
						}
					}, 3000);
				}
			});

			mDialog = new Dialog(context, R.style.Theme_Panel_Volume);
			mDialog.setTitle("Brightness control");
			mDialog.setContentView(mView);
			Window window = mDialog.getWindow();
			window.setGravity(Gravity.TOP);
			LayoutParams lp = window.getAttributes();
			lp.token = null;
			
			lp.y = context.getResources().getDimensionPixelOffset(R.dimen.volume_panel_top);
//			lp.type = LayoutParams.TYPE_VOLUME_OVERLAY;
			lp.type = LayoutParams.TYPE_SYSTEM_ALERT;
			lp.width = LayoutParams.WRAP_CONTENT;
			lp.height = LayoutParams.WRAP_CONTENT;
			window.setAttributes(lp);
			mDialog.show();
			
			timer.scheduleAtFixedRate(new TimerTask() {  
	            public void run() {  
	                if(mDialog.isShowing()){
	                	if (!isSlide) {
							mDialog.dismiss();
						}
	                }
	            }  
	        }, 3000, 1000);  
		}
附上源码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值