प्रदर्शित करें मुझे ग्राफ पृष्ठ में स्थिति है जहां LinearLayout
को TextView
90 डिग्री घूर्णन के साथ प्रदर्शित करना चाहिए।टेक्स्टव्यू 90 डिग्री कैसे घुमाएं और
उत्तर
सबसे तेज और सबसे सुविधाजनक तरीका है तो जैसे अपने नियमित रूप से TextView पर Animation
उपयोग घुमाने एनीमेशन द्वारा Rotate
है।
rotateAnimation.xml:
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="-90"
android:pivotX="50%"
android:duration="0"
android:fillAfter="true" />
जावा कोड:
TextView text = (TextView)findViewById(R.id.txtview);
text.setText("rotated text here");
RotateAnimation rotate= (RotateAnimation)AnimationUtils.loadAnimation(this,R.anim.rotateAnimation);
text.setAnimation(rotate);
यह अच्छा है लेकिन मुझे यह बहुत मदद नहीं मिली है http://stackoverflow.com/questions/1258275/vertical-rotated- लेबल -इन-एंड्रॉइड ने मुझे अपने सीएस – sakshi
किसी भी नए दृश्य के लिए एंड्रॉयड में एक विधि कहा जाता setRotation(float) है आप इसे
textview.setRotation(float);
लेकिन उपयोग कर सकते हैं तो कृपया ध्यान दें कि यह विधि API स्तर 11
में जोड़ा गया हैताकि आप इसे समर्थन करना चाहते हैं, तो आप उपयोग कर सकते इस
if (Build.VERSION.SDK_INT < 11) {
RotateAnimation animation = new RotateAnimation(oldAngel, newAngel);
animation.setDuration(100);
animation.setFillAfter(true);
watermarkText.startAnimation(animation);
} else {
watermarkText.setRotation(progress);
}
में बहुत मदद की है थोड़ा और स्पष्टीकरण अच्छा होगा। –
मैंने अधिक जानकारी –
इस :: प्रयास करें
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:rotation="-95"
android:text="2"
/>
FYI के लिए उत्तर संपादित किया। इसकी आवश्यकता Build.VERSION.SDK_INT> 11 – MilapTank
इस दृष्टिकोण में समस्या चौड़ाई आकार बदलती नहीं है। कोई विचार यह कैसे दूर करने के लिए? – abh22ishek
[हल] किसी भी उपयुक्त बिना मेरी बाल्टी सूची पर इस किया जा रहा है के एक साल बाद मंचों पर जवाब मैंने आखिरकार इसे हल किया है!
यह चाल यहां लेआउट_विड्थ और लेआउट_हेइट को TextView
टेक्स्ट से बड़ा होने के लिए हार्ड-कोड करना है - उदा। 100 डीपी एक्स 100 डीपी।
फिर एक FrameLayout
में TextView
जगह है और FrameLayout
android:clipChildren="false"
के लिए बंद कर देते हैं और कतरन TextView android:clipToPadding="false"
के लिए बंद करने के लिए padding क्लिप:
TextView
with hard-coded height and width
TextView
अब FrameLayout
में तैर सकती है। टेक्स्ट को इसकी सीमा के भीतर ले जाने के लिए TextView
गुरुत्वाकर्षण सेटिंग्स का उपयोग करें।
तो यह भीतर माता पिता FrameLayout
भीतर सीमा स्थानांतरित करने के लिए layout_gravity सेटिंग्स का उपयोग करें:
:
यहाँ सही और नीचे गठबंधन पाठ का एक उदाहरण के माध्यम से -90 डिग्री घुमाया है [अद्यतन] फ्रेम दृश्य आवास घूर्णन पाठ के लिए उदाहरण एक्सएमएल:
<FrameLayout
android:layout_width="@dimen/item_col_width_val"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:padding="@dimen/table_header_margin">
<TextView
android:layout_width="@dimen/table_title_row_height"
android:layout_height="@dimen/table_title_row_height"
android:layout_gravity="bottom|end"
android:gravity="bottom"
android:rotation="-90"
android:text="@string/asm_col_title_in_stock"
android:textColor="@color/colorGood" />
</FrameLayout>
कृपया अपना एक्सएमएल कोड साझा करें ताकि हम आपके उत्तर की व्याख्या को और अधिक तेज़ी से समझ सकें। – ProgDevCode
@ProgDevCode ने अनुरोध के रूप में कुछ एक्सएमएल जोड़ा। – user7653815
<TextView
android:id="@+id/rotated_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:alpha=".3"
android:background="@drawable/grey_capsule"
android:gravity="center"
android:textColor="@android:color/white"
android:textSize="14sp"
android:padding="4dp"
android:layout_marginLeft="-50dp"
android:rotation="-90"
android:text="Andrew Coder" />
धन्यवाद ........... –
यदि आपको एनीमेशन की आवश्यकता नहीं है तो आप एक समान question में दिए गए समाधान का प्रयास कर सकते हैं। एक पाठ नीचे से ऊपर तक लिखा जाएगा।
- पाठ का आकार
- पाठ रंग
- पाठ फ़ॉन्ट
- पाठ गद्दी
- XML के माध्यम से उपयोग
मुख्य बात करने के लिए है:
यह सभी बुनियादी TextView सुविधाओं का समर्थन करता ओवरराइड onDraw()
और,210 तरीकों अपने पाठ का मापदंडों के आधार पर:
@Override
protected void onDraw(Canvas canvas)
{
super.onDraw(canvas);
if (!this._text.isEmpty())
{
float textHorizontallyCenteredOriginX = this._measuredHeight/2f;
float textHorizontallyCenteredOriginY = this._ascent;
canvas.translate(textHorizontallyCenteredOriginY, textHorizontallyCenteredOriginX);
canvas.rotate(-90);
canvas.drawText(this._text, 0, 0, this._textPaint);
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
try
{
this._textPaint.getTextBounds(this._text, 0, this._text.length(), this._textBounds);
this._tempView = new TextView(getContext());
this._tempView.setPadding(this._leftPadding, this._topPadding, this._rightPadding, this._bottomPadding);
this._tempView.setText(this._text);
this._tempView.setTextSize(TypedValue.COMPLEX_UNIT_PX, this._textSize);
this._tempView.setTypeface(this._typeface);
this._tempView.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
this._measuredWidth = this._tempView.getMeasuredHeight();
this._measuredHeight = this._tempView.getMeasuredWidth();
this._ascent = this._textBounds.height()/2 + this._measuredWidth/2;
setMeasuredDimension(this._measuredWidth, this._measuredHeight);
}
catch (Exception e)
{
setMeasuredDimension(widthMeasureSpec, heightMeasureSpec);
Log.e(LOG_TAG, Log.getStackTraceString(e));
}
}
कृपया, पूर्ण स्रोत कोड को देखने के लिए Vertical (rotated) label in Android पर एक नज़र डालें।
- 1. सी # घुमाएं बिटमैप 90 डिग्री
- 2. घुमाएं देखें पदानुक्रम 90 डिग्री
- 3. एक कैलियर 90 डिग्री घूर्णन?
- 4. एंड्रॉइड एक कैमरा बिटमैप का अभिविन्यास प्राप्त करें? और वापस -90 डिग्री घुमाएं
- 5. एंड्रॉइड: 90 डिग्री से घूर्णन अक्षम करें, लेकिन 180 डिग्री
- 6. n डिग्री है, जहां n 90
- 7. ज़ैक्सिंग - कैमरा दृश्य बदलना -90 डिग्री
- 8. लॉसलेस जेपीईजी घुमाव (90/180/270 डिग्री)?
- 9. बेवकूफ छवि - घुमाएं मैट्रिक्स 270 डिग्री
- 10. एंड्रॉइड स्क्वैश छवि में बिटमैप 90 डिग्री परिणाम घुमाएं। चित्र और परिदृश्य के बीच एक सच्चे घुमाव की आवश्यकता है
- 11. टेक्स्टव्यू
- 12. घुमाएं UIView iPhone
- 13. तालिका 45 डिग्री घुमाएं और परिणाम को दूसरी तालिका में कैसे सहेजें?
- 14. रिपोर्टिंग सेवाओं में एक टेबल घुमाएं?
- 15. 360 डिग्री
- 16. आईफोन घुमाए जाने पर 90 डिग्री घुमाए जाने पर फ़ंक्शन को ट्रिगर कैसे करें?
- 17. मैं अपने ऊपरी दाएं कोने से UIView 90 डिग्री को कैसे एनिमेट/घुमा सकता हूं?
- 18. jQuery घुमाएं/
- 19. 45 डिग्री
- 20. एंड्रॉइड 90 डिग्री (कैमरे द्वारा लिया गया) द्वारा चित्रों को घुमाता है
- 21. जावा - एक शासक (90 डिग्री कोण पर टिक अंकों के साथ लाइन)
- 22. फोरट्रान 90
- 23. टेक्स्टव्यू
- 24. आईई में टेक्स्ट घुमाएं, बिना बदसूरत
- 25. आईफोन छवि कैमरे से घूमती है -90 डिग्री स्वचालित रूप से
- 26. एंड्रॉइड - क्या टोस्ट 90 डिग्री घुमाए जाने का कोई तरीका है?
- 27. टेक्स्टव्यू
- 28. टेक्स्टव्यू
- 29. टेक्स्टव्यू
- 30. टेक्स्टव्यू
http://stackoverflow.com/questions/1258275/vertical-rotated-label-in-android ने इसे चेक किया और मेरी समस्या हल की – sakshi
एपीआई 11 (एंड्रॉइड 3.0) के रूप में एक्सएमएल में ऐसा करना संभव है। http://stackoverflow.com/questions/3774770/sideways-view-with-xml-android – chobok