मैं कुछ दिनों के लिए एल पूर्वावलोकन के साथ खेल रहा है, और एक बात यह है कि काम करने के लिए प्रतीत नहीं होता है एक दृश्य के लिए android:elevation
विशेषता है। View.setElevation()
पर कॉल करते समय यह ठीक काम करता है, लेकिन ऐसा लगता है कि यह XML विशेषता को अनदेखा करता है। मैं एंड्रॉयड स्टूडियो 0.8.2 का उपयोग कर रहा है और minSdkVersion
और 'L'
करने के लिए targetSdkVersion
सेट, और 'android-L'
करने के लिए compileSdkVersion
सेट है। buildToolsVersion
"20.0.0"
है।एंड्रॉयड: ऊंचाई एल पूर्वावलोकन में काम नहीं करता है
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_margin="10dp"
android:elevation="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="top"/>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_margin="10dp"
android:elevation="0dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="bottom"/>
</android.support.v7.widget.CardView>
</LinearLayout>
यहाँ परिणाम का एक स्क्रीनशॉट है:: यहाँ एक नमूना लेआउट कि ठीक से काम नहीं करता है imgur.com/mqeq9vK
android:elevation
मैं सेट के अनुसार, नीचे कार्ड फ्लैट पर होना चाहिए "जमीन", लेकिन यह नहीं है। वास्तव में, यह कोई शीर्ष कार्ड जो ऊंचाई 5dp
है से अलग दिखता है। क्या यह एक ज्ञात मुद्दा है, और क्या यह आपके लिए काम करता है?
संपादित करें: ऐसा लगता है कि यह केवल CardView
के साथ मामला है, या कम से कम यह Buttons
के साथ कोई समस्या नहीं है। इस लेआउट में मैं Button
साथ CardView
बदल दिया, और भले ही छाया तरह का बँधा हुआ है (ज्ञात बग), तब भी आप ऊंचाई में अंतर देख सकते हैं।
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="2dp"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="1dp"/>
</LinearLayout>
संपादित करें 2: यह बहुत ज्यादा पुष्टि की है कि इस मुद्दे को केवल CardView
, android:elevation
किसी अन्य दृश्य के लिए ठीक काम करता है को प्रभावित करता है है। यह क्यों होता है इसका एक विस्तृत स्पष्टीकरण के लिए स्वीकृत उत्तर को देखें। इस बीच में, मेरी वैकल्पिक हल एक FrameLayout
साथ CardView
की जगह और एक drawable को android:background
स्थापित करने के लिए है।
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#fff" />
</shape>
मैं भी एक बग के रूप में यह मामला दर्ज किया है, तो कृपया इस मुद्दे को स्टार यह आपको प्रभावित करता है, तो: यहाँ एक कार्ड पृष्ठभूमि drawable कि काम करता है का एक उदाहरण है। https://code.google.com/p/android-developer-preview/issues/detail?id=731
धन्यवाद के लिए कोड है, यह मैं क्या संदिग्ध पुष्टि करता है। मैं उस बग को फाइल करूंगा और उस समय में मैं एक अलग विधि का काम करूंगा। – IvonLiu
@alanv क्या आप जानते हैं कि यह अभी भी एक बग है कि लॉलीपॉप आधिकारिक तौर पर बाहर है? मैं अभी भी इसे एक्सएमएल में काम नहीं कर सकता। – KickingLettuce
आपको कार्ड एलिवेशन प्रॉपर्टी का उपयोग करना चाहिए (जैसा कि यज्ञ से दूसरे उत्तर में बताया गया है, जो कार्डव्यू के लिए डेवलपर है)। – alanv