layout - Android custom dialog linearlayout size same as dialogs bg image -


मैं एक कस्टम संवाद बना रहा हूँ जैसा कि:

  डायलॉग myDialog = new dialog (context, R.style.Theme_Levels); myDialog.setContentView (R.layout.levelselector); myDialog.show ();   

शैली का उपयोग किया गया:

  & lt; शैली का नाम = "थीम। लेवल" मूल = "@ एंड्रॉइड: शैली / थीम। डायलॉग" & gt; & Lt; आइटम का नाम = "android: windowFrame" & gt; @ null & lt; / item & gt; & Lt; आइटम का नाम = "android: windowIs फ़्लोटिंग" & gt; सत्य & lt; / item & gt; & Lt; आइटम का नाम = "android: windowBackground" & gt; @ ड्रॉएबल / डीएलजीबीजी & lt; / item & gt; & Lt; आइटम का नाम = "android: windowContentOverlay" & gt; @ null & lt; / item & gt; & Lt; आइटम का नाम = "android: windowSoftInputMode" & gt; राज्य अनिर्दिष्ट है; समायोजन करें & lt; / आइटम & gt; & Lt; आइटम का नाम = "android: windowNoTitle" & gt; सच & lt; / item & gt; & Lt; आइटम का नाम = "android: backgroundDimEnabled" & gt; गलत & lt; / item & gt; & Lt; / शैली & gt;   

लेआउट xml फ़ाइल:

  & lt; linearLayout एंड्रॉइड: id = "@ + आईडी / स्तर चयनकर्ता" xmlns: android = "http: // स्कीमास Android.com/apk/res/android "android: layout_height =" fill_parent "android: layout_width =" fill_parent "एंड्रॉइड: लेआउट_ग्राविटी =" नीचे | केंद्र_हायज़ॉन्टल "एंड्रॉइड: पैडिंगबोटम =" 50 डीपी "& gt; & Lt; बटन एंड्रॉइड: टेक्स्ट = "आसान" एंड्रॉइड: एंड्रॉइड: एंड्रॉयड: id = "@ + आईडी / बीटीएन_ईसी" एंड्रॉइड: layout_width = "wrap_content" एंड्रॉइड: layout_height = "wrap_content" / & gt; & Lt; / LinearLayout & gt;   

मुझे लगता है कि बटन संवाद के नीचे केंद्र पर दिखाई देगा (नीचे से 50 डीप पैडिंग) परन्तु यह डायलॉग के ऊपर बाईं तरफ दिखाई देता है।

यह है क्योंकि रैखिकरेखा संवाद की चौड़ाई / ऊंचाई को नहीं जानता, जो कि पृष्ठभूमि छवि का आकार है जिसे मैंने शैली xml फ़ाइल में उपयोग किया है।

प्रश्न: मैं कैसे जान सकता हूँ डायलॉग आकार की समान चौड़ाई की है ताकि डायलॉग आकार के रूप में एक ही आकार का हो?

यहाँ है आप यह कैसे कर सकते हैं:

  & lt; linearLayout xmlns: android = "http://schemas.android.com/apk/res/android" एंड्रॉइड: id = "@ + आईडी / स्तर चयनकर्ता "Android: layout_height =" fill_parent "android: layout_width =" fill_parent "एंड्रॉइड: अभिविन्यास =" ऊर्ध्वाधर "एंड्रॉइड: पैडिंगबोटम =" 50 डीपी "& gt; & Lt; एंड्रॉइड देखें: layout_width = "0dp" एंड्रॉइड: layout_height = "0dp" एंड्रॉइड: लेआउट_वेट = "1" / & gt; & Lt; बटन एंड्रॉइड: टेक्स्ट = "आसान" एंड्रॉइड: एडी = "@ + आईडी / बीटीएन_ईसी" एंड्रॉइड: लेआउट_ग्राविटी = "केंद्र_हायज़ॉन्टल" एंड्रॉइड: लेआउट_विंड = "लपेटो-सामग्री" एंड्रॉइड: layout_height = "wrap_content" / & gt; & Lt; / LinearLayout & gt;    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -