title: Buttons of alert dialog are cut off
body: <p>I have an alert dialog which is started when someone touches a specific button. The alert dialog contains a view that is defined by a layout xml file. This layout contains several controls like check boxes, edit text fields, ... These controls are all inside a scrool view so that you can scroll through the content, if the whole content doesn't fit on the screen.</p>
  
  <p>The problem is now that when I start this alert dialog, the buttons at the bottom are cut off screen. Altough the scrool bar is working and I can scroll through the content of the alert dialog, the buttons of the alert dialog are sometimes not totally visible.</p>
  
  <p>This means:
  Sometimes, all is fine and I can see the buttons of the alert dialog, an sometimes for strange reason, the buttons are cut off. I think it's an issue of the view being to big for the alert dialog and pushing the buttons more down.
  For example, the view contains an edit text control. If I enter my name ther, everything is fine. But if I add a new line to this edit text, the buttons start to be cut off a little bit. 
  What did I wrong? I thought the scroll view would handle the oversize of my view so that the alert dialog fits to the screen.
  My app is in portrait mode always.</p>
  
  <p>The code of the view:</p>
  
  <pre><code>&lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/scrollView2"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fillViewport="true" &gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical"
          android:padding="5dp" &gt;
  
          &lt;TextView
              android:id="@+id/textView1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/bitteeinstellungenwaehlen" /&gt;
  
          &lt;EditText
              android:id="@+id/edtTeam1"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:ems="10"
              android:hint="@string/hteam1"
              android:text="Christoph" &gt;
  
              &lt;requestFocus /&gt;
          &lt;/EditText&gt;
  
          &lt;EditText
              android:id="@+id/edtTeam2"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:ems="10"
              android:hint="@string/hteam2"
              android:text="Lea" /&gt;
  
          &lt;EditText
              android:id="@+id/edtTeam3"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:ems="10"
              android:hint="@string/hteam3"
              android:text="Ludwig" /&gt;
  
          &lt;EditText
              android:id="@+id/edtTeam4"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:ems="10"
              android:hint="@string/hteam4"
              android:text="Anja" /&gt;
  
          &lt;TextView
              android:id="@+id/textView2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/weitereeinstellungen" /&gt;
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content" &gt;
  
              &lt;CheckBox
                  android:id="@+id/chkModerationMode"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="@string/moderationsmodus" /&gt;
  
              &lt;TextView
                  android:id="@+id/textView3"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginLeft="10dp"
                  android:text="@string/info" /&gt;
  
          &lt;/LinearLayout&gt;
  
          &lt;CheckBox
              android:id="@+id/chkPassOver"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:checked="true"
              android:text="@string/weitergeben" /&gt;
  
          &lt;CheckBox
              android:id="@+id/chkBlackScreen"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/blankscreen" /&gt;
  
      &lt;/LinearLayout&gt;
  
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p>And that's how I start the alert dialog:</p>
  
  <pre><code>    final AlertDialog.Builder alert = new AlertDialog.Builder(QuizEditor.this);
  
      alert.setTitle(getString(R.string.speichernUndVorschau) + "...");
      alert.setMessage("");
  
  
      LayoutInflater inflater = LayoutInflater.from(QuizEditor.this);
      final View layFrage = inflater.inflate(R.layout.layoutquizsettings,null);
      alert.setView(layFrage);
  
      final CheckBox chkModeration = (CheckBox) layFrage.findViewById(R.id.chkModerationMode);
      final CheckBox chkPassOver = (CheckBox) layFrage.findViewById(R.id.chkPassOver);
      final CheckBox chkBlackScreen = (CheckBox) layFrage.findViewById(R.id.chkBlackScreen);
  
      final EditText edtTeam1 = (EditText) layFrage.findViewById(R.id.edtTeam1);
      final EditText edtTeam2 = (EditText) layFrage.findViewById(R.id.edtTeam2);
      final EditText edtTeam3 = (EditText) layFrage.findViewById(R.id.edtTeam3);
      final EditText edtTeam4 = (EditText) layFrage.findViewById(R.id.edtTeam4);
  
  
  
      alert.setNeutralButton(getString(R.string.speichernUndVorschau), new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int whichButton) {
  
  
  
  
      }
      });
  
      alert.setNegativeButton(getString(R.string.abbrechen), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
          // Canceled.
        }
      });
  
  
  
      final AlertDialog dialog2 = alert.create();
  
      dialog2.setOnShowListener(new OnShowListener() {
  
          @Override
          public void onShow(DialogInterface dialog) {
              // TODO Auto-generated method stub
              Button btnStarten = (Button) dialog2.getButton(AlertDialog.BUTTON_NEUTRAL);
              btnStarten.setOnClickListener(new OnClickListener() {
  
                  @Override
                  public void onClick(View v) {
                      // TODO Auto-generated method stub
                      ArrayList&lt;String&gt; teams = new ArrayList&lt;String&gt;();
  
                      String team1 = edtTeam1.getText().toString().trim();
                      String team2 = edtTeam2.getText().toString().trim();
                      String team3 = edtTeam3.getText().toString().trim();
                      String team4 = edtTeam4.getText().toString().trim();
  
                      if(team1.length() &gt; 0) teams.add(team1);
                      if(team2.length() &gt; 0) teams.add(team2);
                      if(team3.length() &gt; 0) teams.add(team3);
                      if(team4.length() &gt; 0) teams.add(team4);
  
                      if(teams.size() == 0) {
                          Toast.makeText(QuizEditor.this, getString(R.string.keinteameingegeben), Toast.LENGTH_SHORT).show();
  
                      }
                      else
                      {
                          // Quiz starten
  
  
  
                          dialog2.dismiss();
                          Intent myIntent;
  
                          if(chkBlackScreen.isChecked()) {
                              myIntent = new Intent(QuizEditor.this, BlackScreen.class);
                          }
                          else // Direkt das Quiz starten
                          {
                              myIntent = new Intent(QuizEditor.this, Quiz.class);
                          }
  
  
                          myIntent.putStringArrayListExtra("teams", teams);
                          myIntent.putExtra("moderation", chkModeration.isChecked());
                          myIntent.putExtra("passover", chkPassOver.isChecked());
                          myIntent.putExtra("filename", filename);
  
  
                          QuizEditor.this.startActivity(myIntent);
                      }
                  }
  
              });
  
          }
  
      });
  
      dialog2.show();
      // dialog2.getWindow().setLayout(LayoutParams.WRAP_CONTENT, 300);
  </code></pre>
  
  <p>I am sorry for the German words. In the image you can see the problem.
  Unfortunately I was not allowed to upload the screenshots I made...</p>