`
ableouou
  • 浏览: 73606 次
  • 性别: Icon_minigender_2
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

关于弹出对话框时 标题栏的抖动问题

阅读更多
遇到这个问题是在camera的MenuHelper类中,我们需要的处理就是添加语句:

AlertDialog ad = adBuilder.create();
ad.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
ad.show();
,详细如下

if ((inclusions & INCLUDE_DETAILS_MENU) != 0) {
            MenuItem detailsMenu = menu.add(0, 0, 80, R.string.details)
                    .setOnMenuItemClickListener(
                            new MenuItem.OnMenuItemClickListener() {
                                public boolean onMenuItemClick(MenuItem item) {
                                    onInvoke.run(new MenuCallback() {
                                        public void run(Uri u,
                                                ImageManager.IImage image) {
                                            if (image == null)
                                                return;

                                            AlertDialog.Builder builder = new AlertDialog.Builder(
                                                    activity);

                                            final View d = View.inflate(
                                                    activity,
                                                    R.layout.detailsview, null);

                                            ImageView imageView = (ImageView) d
                                                    .findViewById(R.id.details_thumbnail_image);
                                            imageView.setImageBitmap(image
                                                    .miniThumbBitmap());

                                            TextView textView = (TextView) d
                                                    .findViewById(R.id.details_image_title);
                                            textView.setText(image
                                                    .getDisplayName());

                                            long length = getImageFileSize(image);
                                            String lengthString = lengthString = length < 0 ? ""
                                                    : android.text.format.Formatter
                                                            .formatFileSize(
                                                                    activity,
                                                                    length);
                                            ((TextView) d
                                                    .findViewById(R.id.details_file_size_value))
                                                    .setText(lengthString);

                                            int dimensionWidth = 0;
                                            int dimensionHeight = 0;
                                            if (isImage) {
                                                dimensionWidth = image
                                                        .getWidth();
                                                dimensionHeight = image
                                                        .getHeight();
                                                d
                                                        .findViewById(
                                                                R.id.details_duration_row)
                                                        .setVisibility(
                                                                View.GONE);
                                                d
                                                        .findViewById(
                                                                R.id.details_frame_rate_row)
                                                        .setVisibility(
                                                                View.GONE);
                                                d
                                                        .findViewById(
                                                                R.id.details_bit_rate_row)
                                                        .setVisibility(
                                                                View.GONE);
                                                d
                                                        .findViewById(
                                                                R.id.details_format_row)
                                                        .setVisibility(
                                                                View.GONE);
                                                d.findViewById(
                                                        R.id.details_codec_row)
                                                        .setVisibility(
                                                                View.GONE);
                                            } else {
                                                MediaMetadataRetriever retriever = new MediaMetadataRetriever();
                                                try {
                                                    retriever
                                                            .setMode(MediaMetadataRetriever.MODE_GET_METADATA_ONLY);
                                                    retriever
                                                            .setDataSource(image
                                                                    .getDataPath());
                                                    try {
                                                        dimensionWidth = Integer
                                                                .parseInt(retriever
                                                                        .extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH));
                                                        dimensionHeight = Integer
                                                                .parseInt(retriever
                                                                        .extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT));
                                                    } catch (NumberFormatException e) {
                                                        dimensionWidth = 0;
                                                        dimensionHeight = 0;
                                                    }

                                                    try {
                                                        int durationMs = Integer
                                                                .parseInt(retriever
                                                                        .extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
                                                        String durationValue = formatDuration(
                                                                activity,
                                                                durationMs);
                                                        ((TextView) d
                                                                .findViewById(R.id.details_duration_value))
                                                                .setText(durationValue);
                                                    } catch (NumberFormatException e) {
                                                        d
                                                                .findViewById(
                                                                        R.id.details_frame_rate_row)
                                                                .setVisibility(
                                                                        View.GONE);
                                                    }

                                                    try {
                                                        String frame_rate = String
                                                                .format(
                                                                        activity
                                                                                .getString(R.string.details_fps),
                                                                        Integer
                                                                                .parseInt(retriever
                                                                                        .extractMetadata(MediaMetadataRetriever.METADATA_KEY_FRAME_RATE)));
                                                        ((TextView) d
                                                                .findViewById(R.id.details_frame_rate_value))
                                                                .setText(frame_rate);
                                                    } catch (NumberFormatException e) {
                                                        d
                                                                .findViewById(
                                                                        R.id.details_frame_rate_row)
                                                                .setVisibility(
                                                                        View.GONE);
                                                    }

                                                    try {
                                                        long bitRate = Long
                                                                .parseLong(retriever
                                                                        .extractMetadata(MediaMetadataRetriever.METADATA_KEY_BIT_RATE));
                                                        String bps;
                                                        if (bitRate < 1000000) {
                                                            bps = String
                                                                    .format(
                                                                            activity
                                                                                    .getString(R.string.details_kbps),
                                                                            bitRate / 1000);
                                                        } else {
                                                            bps = String
                                                                    .format(
                                                                            activity
                                                                                    .getString(R.string.details_mbps),
                                                                            ((double) bitRate) / 1000000.0);
                                                        }
                                                        ((TextView) d
                                                                .findViewById(R.id.details_bit_rate_value))
                                                                .setText(bps);
                                                    } catch (NumberFormatException e) {
                                                        d
                                                                .findViewById(
                                                                        R.id.details_bit_rate_row)
                                                                .setVisibility(
                                                                        View.GONE);
                                                    }

                                                    String format = retriever
                                                            .extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_FORMAT);
                                                    ((TextView) d
                                                            .findViewById(R.id.details_format_value))
                                                            .setText(format);

                                                    String codec = retriever
                                                            .extractMetadata(MediaMetadataRetriever.METADATA_KEY_CODEC);

                                                    if (codec == null) {
                                                        d
                                                                .findViewById(
                                                                        R.id.details_codec_row)
                                                                .setVisibility(
                                                                        View.GONE);
                                                    } else {
                                                        ((TextView) d
                                                                .findViewById(R.id.details_codec_value))
                                                                .setText(codec);
                                                    }
                                                } catch (RuntimeException ex) {
                                                    // Assume this is a corrupt
                                                    // video file.
                                                } finally {
                                                    try {
                                                        retriever.release();
                                                    } catch (RuntimeException ex) {
                                                        // Ignore failures while
                                                        // cleaning up.
                                                    }
                                                }
                                            }

                                            String dimensionsString = String
                                                    .format(
                                                            activity
                                                                    .getString(R.string.details_dimension_x),
                                                            dimensionWidth,
                                                            dimensionHeight);
                                            ((TextView) d
                                                    .findViewById(R.id.details_resolution_value))
                                                    .setText(dimensionsString);

                                            String dateString = "";
                                            long dateTaken = image
                                                    .getDateTaken();
                                            if (dateTaken != 0) {
                                                java.util.Date date = new java.util.Date(
                                                        image.getDateTaken());
                                                java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat();
                                                dateString = dateFormat
                                                        .format(date);

                                                ((TextView) d
                                                        .findViewById(R.id.details_date_taken_value))
                                                        .setText(dateString);
                                            } else {
                                                d
                                                        .findViewById(
                                                                R.id.details_date_taken_row)
                                                        .setVisibility(
                                                                View.GONE);
                                            }

                                            builder
                                                    .setNeutralButton(
                                                            R.string.details_ok,
                                                            new DialogInterface.OnClickListener() {
                                                                public void onClick(
                                                                        DialogInterface dialog,
                                                                        int which) {
                                                                    dialog
                                                                            .dismiss();
                                                                }
                                                            });

                                            builder
                                                    .setIcon(
                                                            android.R.drawable.ic_dialog_info)
                                                    .setTitle(
                                                            R.string.details_panel_title)
                                                    .setView(d);
                                           
                                            AlertDialog able = builder.create();
                                            able
                                                    .getWindow()
                                                    .setFlags(
                                                            WindowManager.LayoutParams.FLAG_FULLSCREEN,
                                                            WindowManager.LayoutParams.FLAG_FULLSCREEN);
                                            able.show();
                                        }
                                    });
                                    return true;
                                }
                            });
            detailsMenu.setIcon(R.drawable.ic_menu_view_details);
        }
分享到:
评论

相关推荐

    JavaScript网页特效范例宝典源码

    实例009 关闭IE主窗口时,不弹出询问对话框 13 1.2 弹出网页对话框 14 实例010 弹出网页模式对话框 14 实例011 弹出全屏显示的网页模式对话框 16 实例012 网页拾色器 18 实例013 日期选择器 21 1.3 窗口的动画效果 ...

    udp异步文本通信,采用timer和udpclient以及回调委托实现

    5. **对话框显示文本**:“点击会弹出文本具体内容的对话框”意味着当收到消息时,会创建一个新的窗口或对话框显示内容。这可能涉及到Windows Forms的`MessageBox`或自定义的窗体控件。 实现这个功能的步骤可能包括...

    VISUAL_C++MFC扩展编程实例(第一部分)

    3. **客户区和非客户区**:客户区是指窗口中可以用来绘制内容的部分,而非客户区包括窗口边框、标题栏等。 4. **重叠窗口、弹出窗口和子窗口**:这些不同类型的窗口在用户界面上有着不同的显示方式和行为特征。 5. *...

    Java开发实战1200例(第1卷).(清华出版.李钟尉.陈丹丹).part3

    实例255 拖动没有标题栏的窗体 325 实例256 取消窗体标题栏与边框 326 实例257 设置闪烁的标题栏 328 11.4 设置窗体的背景 329 实例258 设置窗体背景颜色为淡蓝色 329 实例259 实现带背景图片的窗体 330 实例260 使...

    javascript网页特效实例大全

    5.7 鼠标右键弹出对话框 102 5.8 鼠标的图片旋转跟踪 103 5.9 旋转的鼠标光环 105 5.10 跟随鼠标旋转的文字 107 5.11 单击鼠标右键打开网站 109 5.12 跟着鼠标的烟花 109 5.13 跟随鼠标的时钟 111 5.14 屏蔽...

    VISUAL C++MFC扩展编程实例(想学MFC的朋友一定不要错过)

    1.1.4 重叠窗口、弹出窗口和子窗口 2 1.1.5 父窗口和宿主窗口 3 1.2 Windows消息 3 1.2.1 发送或寄送消息 4 1.2.2 消息类型 4 1.2.3 接收消息 4 1.2.4 窗口处理函数的子类化 5 1.3 窗口绘图 5 1.3.1 设备环境 5 ...

    一份很实用的MFC资料

    1.1.4 重叠窗口、弹出窗口和子窗口 2 1.1.5 父窗口和宿主窗口 3 1.2 Windows消息 3 1.2.1 发送或寄送消息 4 1.2.2 消息类型 4 1.2.3 接收消息 4 1.2.4 窗口处理函数的子类化 5 1.3 窗口绘图 5 1.3.1 设备环境 5 ...

    VISUAL C MFC扩展编程实例与源码

    1.1.4 重叠窗口、弹出窗口和子窗口 2 1.1.5 父窗口和宿主窗口 3 1.2 Windows消息 3 1.2.1 发送或寄送消息 4 1.2.2 消息类型 4 1.2.3 接收消息 4 1.2.4 窗口处理函数的子类化 5 1.3 窗口绘图 5 1.3.1 设备...

    VISUAL C++MFC扩展编程实例

    1.1.4 重叠窗口、弹出窗口和子窗口 2 1.1.5 父窗口和宿主窗口 3 1.2 Windows消息 3 1.2.1 发送或寄送消息 4 1.2.2 消息类型 4 1.2.3 接收消息 4 1.2.4 窗口处理函数的子类化 5 1.3 窗口绘图 5 1.3.1 设备环境 5 ...

    vc++ 应用源码包_1

    内含各种例子(vc下各种控件的使用方法、标题栏与菜单栏、工具栏与状态栏、图标与光标、程序窗口、程序控制、进程与线程、字符串、文件读写操作、文件与文件夹属性操作、文件与文件夹系统操作、系统控制操作、程序...

    vc++ 应用源码包_2

    内含各种例子(vc下各种控件的使用方法、标题栏与菜单栏、工具栏与状态栏、图标与光标、程序窗口、程序控制、进程与线程、字符串、文件读写操作、文件与文件夹属性操作、文件与文件夹系统操作、系统控制操作、程序...

Global site tag (gtag.js) - Google Analytics