2013-07-25 6 views
5

के रूप में नीचे चित्र में देखा मैं 4 संकल्प फ़ोल्डरों बनाया है और प्रत्येक में उचित छवि आकार डाल दिया है:स्केल छवियाँ एक्सएमएल

enter image description here

मैं भी विभिन्न स्क्रीन के लिए 8 अलग लेआउट फ़ोल्डरों बनाया है आकार के रूप में नीचे चित्र में देखी गई:

enter image description here

आप नीचे चित्र में देख सकते हैं, मैं हर अनुसार एक्सएमएल फ़ाइल में फिर से आकार के लिए छवियों को तो वे वें भरने की जरूरत है ई स्क्रीन:

enter image description here

मैं जो ठीक काम करता है छवियों नीचे पैमाने पर करने के लिए इस कोड का उपयोग करें:

android:adjustViewBounds="true" 
    android:maxWidth="150dp" 
    android:scaleType="fitCenter" 

लेकिन मैं समझ नहीं छवियों को पैमाने पर करने के लिए कैसे। मैं इस कोड का उपयोग करने की कोशिश कर रहा हूं:

android:adjustViewBounds="true" 
    android:minWidth="150dp" 
    android:scaleType="fitCenter" 

छवियों को स्केल करने के तरीके पर कोई विचार? धन्यवाद!!

एक्सएमएल:

<ImageButton 
    android:id="@+id/btnPlay" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_below="@+id/imageView1" 
    android:layout_marginTop="15dp" 
    android:background="@null" 
    android:src="@drawable/btn_play" 
    android:adjustViewBounds="true" 
    android:scaleX="1.5" 
    android:scaleY="1.5" 
    android:scaleType="fitXY" /> 

उत्तर

6

आप की कोशिश की है ?:

android:scaleX="1.5" // 1 is 100% size 
android:scaleY="1.5" 
+1

यह वास्तविक छवि को फिर से आकार देने में काम करता है लेकिन छवि दृश्य इसके साथ स्केल नहीं करता है इसलिए चित्र ओवरलैप होते हैं। इमेज के साथ इमेज व्यू स्केल बनाने के बारे में कोई विचार? – Shane

+0

और आप ऊंचाई/चौड़ाई 'wrap_content' का उपयोग नहीं कर सकते हैं, है ना? –

+0

हां, मेरे पास एंड्रॉइड है: layout_width = "wrap_content" और एंड्रॉइड: image_iewidth = "wrap_content" छवि पर देखें – Shane

1

android:scaleType="fitXY" बजाय android:scaleType="fitCenter"

कोशिश संपादित

उपयोग LinearLayoutlayout_weight and weightSum

तरह समायोजित WeighSum और layout_weight के साथ अपने UI के अनुसार!

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:weightSum="8" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="3" > 

     <!-- your Match m Image --> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="2" 
     android:background="#fff" > 

     <!-- your play image --> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" > 

     <!-- your Multiplayer image --> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" > 

     <!-- your High score Image --> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" > 

     <!-- your how to play Image --> 
    </LinearLayout> 
</LinearLayout> 
+0

परीक्षण किया गया, लेकिन छवियां अभी भी स्केल नहीं होंगी। – Shane

+0

@ शेन उपयोग एंड्रॉइड: layout_width = "match_parent" और एंड्रॉइड: layout_width = "match_parent" –

+0

"match_parent" पूरी स्क्रीन को छवि दृश्य के साथ भरता है।मैंने लेआउट_वेट और वेटसम – Shane

0

आप इसके लिए नए आकार क्वालीफायर का उपयोग करेंगे। यह सबसे अच्छा तरीका है। आप जो कर रहे हैं वह गलत नहीं है, लेकिन उपकरणों की इतनी सारी नस्लों के साथ यह अप्रचलित हो गया है। this

+0

एंड्रॉइड 3.2 में आकार क्वालीफायर पेश किए गए थे। मेरे आवेदन को कम से कम एपीआई 8 का समर्थन करने की आवश्यकता है। – Shane

संबंधित मुद्दे