当显示软键盘时,如果显示对话框,布局中会出现一个小的混蛋

时间:2016-07-12 09:01:11

标签: android dialog android-softkeyboard

正如我在标题中提到的,我的问题是当显示软键盘时如果显示对话框,布局中有一个小的混蛋,它非常小但我不想要它。

以下是我使用的代码。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Welcome to new page"
    android:layout_gravity="center"
    android:layout_marginTop="30dp"
    android:textSize="30dp"
    android:textColor="#24f40d"
    />

<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:imeOptions="actionDone"
    android:singleLine="true"/>
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="next"
    android:layout_gravity="center"
    android:id="@+id/bt3"/></LinearLayout>

这是内容主要代码。我只想要,如果我们专注于编辑文本键盘将显示,如果我们按下按钮对话框将显示然后在app中有小混蛋。我不想要那样。 如果有人知道解决方案发布它会帮助很多。谢谢提前。

 public class button1layout extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.button1layout);

        Button bt3=(Button)findViewById(R.id.bt3);
        bt3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showChangeLangDialog();
                /*Intent i3=new Intent(button1layout.this,button3layout.class);
                startActivity(i3);*/
            }
        });

    }

    private void showChangeLangDialog() {

        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
        LayoutInflater inflater = this.getLayoutInflater();
        final View dialogView = inflater.inflate(R.layout.custom_dialog, null);
        dialogBuilder.setView(dialogView);

        final EditText edt = (EditText) dialogView.findViewById(R.id.edit1);

        dialogBuilder.setTitle("Custom dialog");
        dialogBuilder.setMessage("Enter text below");
        dialogBuilder.setPositiveButton("Done", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                //do something with edt.getText().toString();
            }
        });
        dialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                //pass
            }
        });
        AlertDialog b = dialogBuilder.create();
        b.show();
    }
}

这是主要活动代码

0 个答案:

没有答案
相关问题