自定义对话框中的ImageView - fill_parent不起作用,对话框很小 [英] ImageView in a Custom Dialog - fill_parent does not work and my dialog is small

查看:290
本文介绍了自定义对话框中的ImageView - fill_parent不起作用,对话框很小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的要求:我必须在一个对话框中放置一些照片(一些小的分辨率,一些大的分辨率)并显示全屏。



我尝试过:

 对话框对话框=新对话框(getActivity()); 
dialog.setContentView(R.layout.custom_dialog);
int picId = Integer.valueOf(webcamCursor.getString(webcamCursor
.getColumnIndex(_ id)));
dialog.setTitle(webcamCursor.getString(webcamCursor
.getColumnIndex(City)));
image =(ImageView)dialog.findViewById(R.id.image);
image.setImageResource(R.drawable.icon);
new DownloadPicTask()。execute(Snippets.getUrlFromCat(picId,cat));
dialog.show();

我的布局是:

 < LinearLayout xmlns:android =http://schemas.android.com/apk/res/android
android:id =@ + id / layout_root
android:orientation =vertical
android:layout_width =fill_parent
android:layout_height =fill_parent
android:layout_gravity =center
>
< ImageView android:id =@ + id / image
android:layout_width =fill_parent
android:layout_height =fill_parent
android:padding =10dip
/>
< / LinearLayout>

当我在任何地方填写fill_parent时,对话框不应该全屏吗?



解决方案

尝试:

  dialog.getWindow()。getAttributes ).width = LayoutParams.FILL_PARENT; 

希望有帮助。


I have a simple request: I have to put some pictures (some small resolution, some big resolution) in a dialog and display them fullscreen.

I tried this:

Dialog dialog = new Dialog(getActivity());
dialog.setContentView(R.layout.custom_dialog);
int picId = Integer.valueOf(webcamCursor.getString(webcamCursor
        .getColumnIndex("_id")));
dialog.setTitle(webcamCursor.getString(webcamCursor
        .getColumnIndex("City")));
image = (ImageView) dialog.findViewById(R.id.image);
image.setImageResource(R.drawable.icon);            
new DownloadPicTask().execute(Snippets.getUrlFromCat(picId, cat));
dialog.show();

And my layout is:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/layout_root"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:layout_gravity="center"
              >
    <ImageView android:id="@+id/image"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent"
               android:padding="10dip"
               />
</LinearLayout>

As I wrote fill_parent everywhere, shouldn't the dialog take the full screen?

解决方案

Try that:

dialog.getWindow().getAttributes().width = LayoutParams.FILL_PARENT;

Hope it helps.

这篇关于自定义对话框中的ImageView - fill_parent不起作用,对话框很小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆