上点击Android的对话框充分屏幕(减去键盘)
问题描述:
行,所以我有一个自定义对话框,它显示如左图。我想点击一个按钮(黑色方块)就可以像屏幕右侧那样全屏显示,但不要在键盘后面。我怎样才能做到这一点?
现在我的对话是这样的
<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);
任何人有一个想法如何做到这一点?
答
试试这个:
myDialog.show();
Window window = myDialog.getWindow();
window.setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
这是正确的!我用这个和之后我也改变了编程有点布局(添加了一些规则,上面,下面等..),它很好!谢谢 –
您能否将代码分享给我。我想要相同的布局。 – Kinjal