2016-05-30 13 views
0

Ich zeige Bild im Dialogfeld an, das auch die Zoomansicht enthält. Hier wird das Bild platziert und der Zoom funktioniert ohne Probleme, aber das Problem ist, dass das Bild immer oben im Dialog platziert wird. Wenn ich nach unten scrolle, kommt es in die Mitte und dann kommt es zu einem Zoom. Ich möchte nicht wie dieses Bild stattdessen in der Mitte angezeigt werden und ich muss den Zoom tun.Bild immer oben im Dialog platziert

Ich verwende dynamische Bildansicht und zum Zoomen mit chrisbanes photoview Bibliothek. Wenn ich die Bibliothek entferne, wird das Bild in der Mitte platziert.

Ich habe versucht mit ScaleType für Bildansicht als Mitte, aber Bild wird oben im Dialogfeld platziert.

enter image description here

enter image description here

+0

warum didt Sie erstellen ein eigenes Dialoglayout? –

+0

Können Sie bitte Ihre Frage ausarbeiten? – user2269164

Antwort

0

Use Custom Dialog für Sie besitzen Dialogdesign

  final Dialog dialog = new Dialog(context); 
      dialog.setContentView(R.layout.custom); 
      dialog.setTitle("Title..."); 

      // set the custom dialog components - text, image and button 
      TextView text = (TextView) dialog.findViewById(R.id.text); 
      text.setText("Android custom dialog example!"); 
      ImageView image = (ImageView) dialog.findViewById(R.id.image); 
      image.setImageResource(R.drawable.ic_launcher); 

      Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK); 
      // if button is clicked, close the custom dialog 
      dialogButton.setOnClickListener(new OnClickListener() { 
       @Override 
       public void onClick(View v) { 
        dialog.dismiss(); 
       } 
      }); 

      dialog.show(); 

Layout:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <ImageView 
     android:id="@+id/image" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginRight="5dp" /> 

    <TextView 
     android:id="@+id/text" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:textColor="#FFF" 
     android:layout_toRightOf="@+id/image"/>/> 

    <Button 
     android:id="@+id/dialogButtonOK" 
     android:layout_width="100px" 
     android:layout_height="wrap_content" 
     android:text=" Ok " 
     android:layout_marginTop="5dp" 
     android:layout_marginRight="5dp" 
     android:layout_below="@+id/image" 
     /> 

</RelativeLayout>