Android自定義Dialog 軟鍵盤、大小的設(shè)置

Dialog中EditText可彈出軟鍵盤

<style name="CustomDialogStyle" parent="@android:style/Theme.Dialog">  
  <item name="android:windowFrame">@null</item>  
  <item name="android:windowIsFloating">true</item>  
  <item name="android:windowIsTranslucent">true</item>  
  <item name="android:windowNoTitle">true</item>  
  <item name="android:background">@android:color/transparent</item>  
  <item name="android:windowBackground">@android:color/transparent</item>  
  <item name="android:backgroundDimEnabled">true</item>  
  <item name="android:backgroundDimAmount">0.6</item>  
</style>

把style設(shè)置到dialog中

Dialog ad = new Dialog(context,R.style.CustomDialogStyle);  
ad.show();  
Window window = ad.getWindow();  
window.setBackgroundDrawable(new ColorDrawable(0));    
window.setContentView(R.layout.cancel_sos_dialog);

Dialog中設(shè)置大小

代碼承接上面的代碼

WindowManager.LayoutParams  lp= window.getAttributes();    
lp.width=screenWidth - 50;//定義寬度    
lp.height=LayoutParams.WRAP_CONTENT;//定義高度    
window.setAttributes(lp);  
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容

  • Android 自定義View的各種姿勢(shì)1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 173,335評(píng)論 25 708
  • ¥開啟¥ 【iAPP實(shí)現(xiàn)進(jìn)入界面執(zhí)行逐一顯】 〖2017-08-25 15:22:14〗 《//首先開一個(gè)線程,因...
    小菜c閱讀 6,523評(píng)論 0 17
  • 你曾說(shuō)過有時(shí)候我們要對(duì)自己殘忍一點(diǎn),不能縱容自己得傷心失望;有時(shí)候我們要對(duì)自己深愛的人殘忍一點(diǎn),將對(duì)他們的記憶擱淺...
    溪月伊人閱讀 700評(píng)論 0 0
  • “不要拋棄我!”我在樹媽媽身上緊貼著,畢竟已經(jīng)一個(gè)年頭了,要想分開我們也不那么容易。可是狂風(fēng)大作,我搖搖擺擺,...
    Mogen閱讀 114評(píng)論 0 2
  • 感覺人很好但不適合在一起的相親對(duì)象,又有共同的朋友,也已經(jīng)明確說(shuō)了他不是我喜歡的類型。每天還是堅(jiān)持不懈地問東問西,...
    喵慫閱讀 137評(píng)論 0 0