2014-10-09 43 views
0

我遇到了對話框消息的問題。直到我想在的EditText上鍵入信息,鍵盤彈出Android對話框setMessage

,一切工作正常 - 然後在對話框的消息的第二個(也是最後一次)線被剪斷一半..

看起來對話框看起來像

圖標名稱:


消息行1

消息行2(< - 半與看得到鍵板)

滾動型與一些edittexts

負按鈕|正面按鍵

編輯:代碼

LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(mContext.LAYOUT_INFLATER_SERVICE); 
      View viewGroup = inflater.inflate(R.layout.layout_dialog_daily_report, null); 
      ScrollView layout = (ScrollView) viewGroup.findViewById(R.id.dialog_parent); 
      final EditText 1 = (EditText) viewGroup.findViewById(R.id.dialog_1); 
      final EditText 2 = (EditText) viewGroup.findViewById(R.id.dialog_2); 
      final EditText 3 = (EditText) viewGroup.findViewById(R.id.dialog_3); 
      final EditText 4 = (EditText) viewGroup.findViewById(R.id.dialog_4); 

      AlertDialog.Builder builder = new AlertDialog.Builder(mContext); 
      builder.setIcon(R.drawable.icon); 
      builder.setTitle(R.string.dialog_title); 
      builder.setMessage(R.string.dialog_message); 
      builder.setView(layout); 
      builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { 

       @Override 
       public void onClick(DialogInterface dialog, int which) { 
       } 
      }); 

      builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { 

       @Override 
       public void onClick(DialogInterface dialog, int which) { 
        dialog.dismiss(); 
       } 
      }); 
      AlertDialog dialog = builder.create(); 
      dialog.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); 
      dialog.show(); 

佈局:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/dialog_parent" 
android:margin="7dp" 
android:layout_width="match_parent" 
android:layout_height="match_parent" > 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.6" 
      android:ellipsize="end" 
      android:text="@string/dialog_1" /> 

     <EditText 
      android:id="@+id/dialog_1" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.4" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.6" 
      android:ellipsize="end" 
      android:text="@string/dialog_2" /> 

     <EditText 
      android:id="@+id/dialog_2" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.4" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.6" 
      android:ellipsize="end" 
      android:text="@string/dialog_3" /> 

     <EditText 
      android:id="@+id/dialog_3" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.4" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.6" 
      android:ellipsize="end" 
      android:text="@string/dialog_4" /> 

     <EditText 
      android:id="@+id/dialog_4" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.4" /> 
    </LinearLayout> 
</LinearLayout> 

enter image description here

正如你所看到的按鈕是不可見的,我不知道爲什麼滾動視圖不再滾動 我該如何預防t表示Dialog.set 消息文本是切斷顯示鍵盤?

+0

把對話框代碼在這裏 – Rustam 2014-10-09 07:32:10

+0

我現在所做的添加對話框代碼;) – Zuop 2014-10-09 07:55:46

+0

http://stackoverflow.com/questions/7200281/programatically-hide-show-android-soft-keyboard – codePG 2014-10-09 08:04:31

回答

0

加入下一行到你的清單:

機器人:windowSoftInputMode = 「adjustResize」

+0

以及我試過,但沒有任何變化。 對話框顯示在監聽器類onClick中,如果有幫助的話。無論如何,滾動視圖不再滾動,我不知道爲什麼我改變了一切回來......現在按鈕被切斷:D – Zuop 2014-10-09 07:53:45

+0

可以分享屏幕截圖嗎? – Amy 2014-10-09 07:54:21

+0

你有解決方案嗎? – Amy 2014-10-09 07:58:24

0

我相信這些錯誤大多是在XML中,嘗試刪除安卓elipsize,也許給layout_width的其他值是0,你可以嘗試