2016-02-19 84 views
0

enter image description here上點擊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); 

任何人有一個想法如何做到這一點?

回答

0

試試這個:

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

這是正確的!我用這個和之後我也改變了編程有點佈局(添加了一些規則,上面,下面等..),它很好!謝謝 –

+0

您能否將代碼分享給我。我想要相同的佈局。 – Kinjal