views:

41

answers:

3

Hello
i create a dialog to zoom on an image,
But my content is 240px and i would like to grow it to phone width, to "fill_parent",
Could you tell me what's wrong here ? my picture stay small 240px, not 480px.
Thanks

final Dialog dialog = new Dialog(myview);
dialog.setContentView(R.layout.zoom);
dialog.setTitle(""+passInfoNom+" ");
imgView2 = (ImageView)dialog.findViewById(R.id.ImageZoom);
imgView2.setImageDrawable(image);
dialog.show();

Layout :

<?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:background="#ffffffff"
>

<ImageView android:id="@+id/ImageZoom" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
</ImageView>
</LinearLayout>
+1  A: 

It looks like you have set the content to "fill_parent" but you have not set the size of the dialog to be "fill_parent." change that and you should see some results.

But i have a question: if you want the zoom dialog to take up the whole screen, why dont you start a new activity, or crop the image and set the cropped portion as the content? it seems weird to me that you would zoom in a dialog. Google maps, for example, just zooms in the existing View.

mtmurdock
i did not want to fill full height, just full width, and i like the dialog UI effect.
NSchubhan
A: 

As the anwser below, i set the size of my dialog, i create my own class Dialog and set dialog size : public class ZoomZoom extends Dialog { public ZoomZoom(Context context) { super(context); }

@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.zoom);
    LayoutParams params = getWindow().getAttributes(); 
    params.width = LayoutParams.FILL_PARENT; 
    //params.height = LayoutParams.FILL_PARENT; 
    params.height = screenLargeur;
    getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);        
    imgView2 = (ImageView)findViewById(R.id.ImageZoom);
    imgView2.setImageDrawable(imageZ);
    imgView2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.hide();
           }
        });
    }
}
NSchubhan
A: 

Not sure if this has been resolved for you but you can also use android:minWidth and android:minHeight, setting them to by dip. For instance:

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/send_chat_layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:background="#292929"
android:minWidth="300dip"
android:minHeight="400dip">

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"/>

</LinearLayout>

From my understanding, due to the way Android scales in resolution, with a 360x480 screen, setting the mins to 340x460 will keep its aspect to larger resolutions.

Alejandro Huerta