<?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);
}
附上源码