首页 > 其他 > 详细

最近开发老遇到莫名其妙的问题,dialog自定义大小,setAttributes这个方法没反应是肿么一回事

时间:2014-09-30 18:05:59      阅读:272      评论:0      收藏:0      [点我收藏+]

====================问题描述====================
最近开发老遇到莫名其妙的问题,dialog自定义大小,setAttributes这个方法没反应是肿么一回事,我只想让dialog显示一部分,但是居然全屏占满了,很费解,以前开发都是这样写的,现在居然不可以了
这是dialog的code
DownLoaderDialog dialog=new DownLoaderDialog(MainActivity.this,R.style.dialog);
Window mwindow=dialog.getWindow();
WindowManager.LayoutParams lp=mwindow.getAttributes();
int[] location = new int[2];
button.getLocationOnScreen(location);
WindowManager m = getWindowManager();
Display d = m.getDefaultDisplay();
lp.y=location[1];
lp.height = (int) (d.getHeight() * 0.6);
mwindow.setAttributes(lp);
dialog.show();

这是dialog的xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0px"
        android:layout_weight="1"
        android:background="#ECEFF0" >

        <ListView
            android:id="@+id/listView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
        </ListView>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="#0BA683"
        android:gravity="center_vertical"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/btnDelete"
            android:layout_width="0px"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/btn_pressed_style"
            android:text="删除"
            android:textColor="#FDFEFE"
            android:textSize="16sp" />

        <View
            android:layout_width="1dp"
            android:layout_height="match_parent"
            
            android:background="#DADBDA" />

        <Button
            android:id="@+id/btnSelectAll"
            android:layout_width="0px"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/btn_pressed_style"
            android:text="全选"
            android:textColor="#FDFEFE"
            android:textSize="16sp" />
    </LinearLayout>

</LinearLayout>

====================解决方案1====================
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" 改 wrap_content试试
    android:layout_height="fill_parent"
    android:orientation="vertical" >
====================解决方案2====================
好奇怪的写法。
====================解决方案3====================
问题应该在R.style.dialog里

最近开发老遇到莫名其妙的问题,dialog自定义大小,setAttributes这个方法没反应是肿么一回事

原文:http://www.cnblogs.com/liangxieliang56/p/4002188.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!