2012-01-12 8 views
3

私は簡単な要求があります:ダイアログにいくつかの画像(ある程度の小さな解像度、大きな解像度)を置いてフルスクリーンで表示する必要があります。カスタムダイアログのImageView - fill_parentが機能せず、ダイアログが小さい

私はこの試みた:

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(); 

をそして、私のレイアウトは次のとおりです。

<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を書いたように、ダイアログがフルスクリーンを取るべきではないのですか?

enter image description here

答えて

8

それを試してみてください。

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

はそれがお役に立てば幸いです。

0
try this will work 

//Grab the window of the dialog, and change the width 
     WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); 
     Window window = dialog.getWindow(); 
     lp.copyFrom(window.getAttributes()); 
     //This makes the dialog take up the full width 
     lp.width = WindowManager.LayoutParams.MATCH_PARENT; 
     lp.height = WindowManager.LayoutParams.MATCH_PARENT; 
     window.setAttributes(lp); 
関連する問題