मेरे पास एक ड्रायबल है, जिसे पृष्ठभूमि के रूप में काम करने की आवश्यकता है। इसे स्क्रीन भरने के लिए खिंचाव की जरूरत है (पहलू अनुपात को अनदेखा कर रहा है)।imageView स्क्रीन फिट करने के लिए खींच नहीं रहा है
मैंने ldpi, mdpi, hdpi और xhdpi के लिए उचित आकार प्रदान किए हैं। (मैं जानता हूँ कि वे इसी चौड़ाई और ऊंचाई के अनुपात से उपयुक्त हैं, वह पर्याप्त है?)
मैं इस प्रकार यह करने के लिए प्रयास किया है:
scaleType का उपयोग कर: imageView पर fitXY
यह छवि दृश्य के चारों ओर एक सफेद मार्जिन छोड़ देता है।
कि चारों ओर एक काम के साथ मैं इस तरह scaleType के लिए केंद्र उपयोग कर रहा है संतुष्ट नहीं कर रहा हूँ:
मैं संतुष्ट नहीं हूँ क्योंकि समस्या अभी भी गोली पर मौजूद है स्क्रीन।
नोट:
- आपने गौर किया हो सकता है, मैं सुझाव फिक्स कहीं इतने पर सही पर देखें सीमाओं को समायोजित की स्थापना की तरह की कोशिश की है। उन्होंने की सहायता नहीं की। :(
- मुझे एक गैर-प्रोग्रामेटिक उत्तर/फिक्स चाहिए, जैसा कि इसे स्वयं एक्सएमएल में करना है। मैं वास्तव में पृष्ठभूमि छवि सेट करने के लिए कोड लिखना नहीं चाहता; जीवन उससे कहीं अधिक सरल होना चाहिए। (: पी)
अद्यतन 1:
यहाँ एक्सएमएल लेआउट
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" -->
<!-- xmlns:tools="http://schemas.android.com/tools" -->
<!-- android:id="@+id/FrameLayout1" -->
<!-- android:layout_width="fill_parent" -->
<!-- android:layout_height="fill_parent" -->
<!-- tools:context=".SplashScreen" > -->
<!--
This FrameLayout insets its children based on system windows using
android:fitsSystemWindows
-->
<View
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:onClick="onClickTapToContinue"
>
</View>
<ImageView
android:id="@+id/bg_gradient"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="fill"
android:adjustViewBounds="true"
android:contentDescription="@string/this_is_the_background_image"
android:scaleType="center"
android:src="@drawable/bg_gradient" />
<ImageView
android:id="@+id/bg_artwork"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:contentDescription="@string/artwork_man"
android:src="@drawable/bg_artwork" />
<!-- </FrameLayout> -->
<ImageView
android:id="@+id/branding"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|top"
android:adjustViewBounds="true"
android:contentDescription="@string/branding_text"
android:maxHeight="95dp"
android:paddingTop="5dp"
android:src="@drawable/title_wlcm" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:paddingBottom="5dp"
android:text="@string/tap_continue"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/white" />
</merge>
मुझे जोड़ने दें कि मैंने अन्य स्केल टाइप विकल्पों का प्रयास किया है और वे इसे ठीक नहीं लग रहे हैं। (जैसा कि WYSIWYG संपादक में देखा गया है) –
आप माता-पिता 'एंड्रॉइड द्वारा पृष्ठभूमि लाइनरलाइट में पृष्ठभूमि जोड़ने का प्रयास कर सकते हैं: पृष्ठभूमि = "@ drawable/bg_gradient" 'layout_width' और' layout_height' के साथ 'match_parent" बराबर है। – pyus13
@ pyus13 मैंने कोशिश की है लेकिन वास्तव में मदद नहीं की है। मुझे इसी तरह के परिणाम मिल गए। और जिस कारण से मैं framelayout का उपयोग कर रहा हूं वह यह है कि: 1) मैं "विलय" कर सकता हूं और एक स्तर के दृश्य पदानुक्रम को खत्म कर सकता हूं 2) ढाल, आदमी, ब्रांडिंग सभी अलग-अलग छवियां हैं जिन्हें ओवरलैप करने की आवश्यकता है –