【问题标题】:Android dialog on click take full screen (minus the keyboard)点击时的Android对话框全屏(减去键盘)
【发布时间】:2016-02-19 14:41:05
【问题描述】:

好的,所以我有一个自定义对话框,它显示为左图。我想点击一个按钮(黑色方块)来像右边的屏幕一样全屏显示,但不要放在键盘后面。我该怎么做?

现在我的对话框是这样的

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/comments_relative_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF" >
<EditText
    android:id="@+id/user_comments"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:gravity="top"
    android:textColor="#000000" />

    <TextView
        android:id="@+id/char_count"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentBottom="true"
        android:text="2048" />
    <Button
        android:id="@+id/fullscreen"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:background="@drawable/full_screen_button_selector"
        android:minHeight="1dp"
        android:minWidth="1dp" />

</RelativeLayout>

我在 onclick 上试过了,但它不起作用

RelativeLayout r = (RelativeLayout) findViewById(R.id.comments_relative_layout);
FrameLayout.LayoutParams _rootLayoutParams = new     
FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
r.setLayoutParams(_rootLayoutParams);

有人知道怎么做吗?

【问题讨论】:

    标签: android user-interface dialog customdialog


    【解决方案1】:

    试试这个:

    myDialog.show();
    Window window = myDialog.getWindow();
    window.setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    

    【讨论】:

    • 没错!我使用了它,之后我还以编程方式更改了一些布局(添加了一些规则,上面,下面等),效果很好!谢谢
    • 能否将代码分享给我。我想要相同的布局。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-21
    • 1970-01-01
    • 1970-01-01
    • 2022-07-23
    相关资源
    最近更新 更多