2012-06-28 14 views
35

से घुमाएँ imageView स्रोत मैं अपने लेआउट में इस imageView है:लेआउट xml फ़ाइल

<ImageView android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:contentDescription="@string/image_divider" 
     android:paddingBottom="8dp" 
     android:paddingTop="4dp" 
     android:scaleType="fitXY" 
     android:src="@android:drawable/divider_horizontal_textfield" /> 

यह एक क्षैतिज विभक्त है। मैं इसे 90 डिग्री घुमाने के लिए चाहता हूं तो मेरे पास एक लंबवत विभक्त है।
क्या यहां लेआउट से ऐसा करने का कोई संभावित तरीका है और गतिविधि वर्ग नहीं है?

+0

तुम सिर्फ 'layout_height =" fill_parent "' करने के लिए ऊंचाई सेट कर सकते हैं और फिर यह सब लेआउट – thepoosh

+0

पर फैला हो जाएगा कृपया स्वीकार/वोट दें जवाब अगर आपको अपना समाधान मिला है :) –

+0

@thepoosh: स्रोत छवि एक वर्ग नहीं है। यह एक विस्तृत आयताकार है और आप जो कहते हैं वह कर रहे हैं, जिसके परिणामस्वरूप पतली ऊर्ध्वाधर आयत होगी। – mehrmoudi

उत्तर

104

आप उपयोग कर सकते हैं उपलब्ध के बाद से एपीआई स्तर 11

android:rotation="90" 

अंतिम कोड डालना उचित,

<ImageView android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:rotation="90" 
     android:contentDescription="@string/image_divider" 
     android:paddingBottom="8dp" 
     android:paddingTop="4dp" 
     android:scaleType="fitXY" 
     android:src="@android:drawable/divider_horizontal_textfield" /> 
+1

धन्यवाद, लेकिन कम से कम मेरे में ImageView के लिए ऐसी कोई विशेषता नहीं है! http://s15.postimage.org/gpit1dvrd/Untitled.png – mehrmoudi

+0

@Mehran http://developer.android.com/reference/android/view/View.html#attr_android:rotation अधिक जानकारी के लिए –

+1

मैं असहमत हूं: एंड्रॉइड : रोमांस विशेषता केवल एपीआई 11 के बाद उपलब्ध है: http://developer.android.com/reference/android/R.attr.html#rotation –

1

आप क्या कर सकते हैं कि एक नया बिटमैप वस्तु बनाने के द्वारा अपने कोड में। चेक इस बाहर: http://android-er.blogspot.fr/2010/07/rotate-bitmap-image-using-matrix.html और विशेष रूप से इस समारोह

Matrix matrix = new Matrix(); 
matrix.postScale(curScale, curScale); 
matrix.postRotate(curRotate); 

Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bmpWidth, bmpHeight, matrix, true); 
myImageView.setImageBitmap(resizedBitmap); 
संबंधित मुद्दे