मैं टेक्स्ट की आधार रेखा पर अपना ImageSpan
संरेखित करना चाहता हूं, लेकिन मुझे लाइनों के बीच कुछ अंतर जोड़ने की भी आवश्यकता है।
समस्या यह है कि जब मैं लाइन स्पेसिंग जोड़ता हूं, तो ImageSpan
टेक्स्ट की आधार रेखा से संरेखित नहीं होता है, लेकिन baseline+lineSpacing
पर, इसलिए यह उससे कम दिखाई दे रहा है।ImageSpan.ALIGN_BASELINE जब टेक्स्ट व्यू में लाइन है
क्या इसके लिए कोई कामकाज है?
संपादित करें: आगे स्पष्टीकरण:
बिना तरह
lineSpacing
यह कैसा दिखता है (तीरImageSpan
है)। यह आधार रेखा से सही ढंग से गठबंधन है।
यह कैसे की तरह अगर मैं जोड़ने
android:lineSpacingMulitiplier="1.2"
संपादित 2 कोड दिखता है:
एक्सएमएल:
<com.kushtrim.example.views.CustomTypefaceTextView
android:id="@+id/descId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="3"
android:gravity="center_vertical"
android:layout_marginLeft="@dimen/_45"
android:layout_marginTop="@dimen/_6"
android:layout_marginBottom="@dimen/_20"
app:font_type="merriweather_regular"
android:textSize="@dimen/f40"
android:lineSpacingMultiplier="1.2"
android:textColor="@color/black"
android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit."
android:ellipsize="end" />
अन्य प्रासंगिक तरीके:
private Spannable getContentText(ContactRaport contactRaport) {
DateTime dateTime = new DateTime(contactRaport.contactDate);
String datePart = dateTime.getDayOfMonth() + " " + dateTime.monthOfYear().getAsShortText(new Locale("nl")) + "; ";
String completeText = datePart + contactRaport.note;
Typeface font1 = Typeface.createFromAsset(context.getAssets(), "MyFont1.ttf");
Typeface font2 = Typeface.createFromAsset(context.getAssets(), "MyFont2.ttf");
SpannableStringBuilder spannable = new SpannableStringBuilder("XX");
ImageSpan arrow = getArrowImageSpan(contactRaport);
spannable.setSpan(arrow, 0, 2, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
spannable.append(completeText);
spannable.setSpan(new CustomTypefaceSpan("", font1), 2, datePart.length()+1, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
spannable.setSpan(new CustomTypefaceSpan("", font2), datePart.length(), completeText.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
spannable.setSpan(new ForegroundColorSpan(getContentDateColor(contactRaport)),2, datePart.length()+1, 0);
return spannable;
}
।
private ImageSpan getArrowImageSpan(ContactRaport contactRaport) {
Drawable d = null;
switch (contactRaport.type) {
... logic to load the correct drawable
}
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
return new ImageSpan(d, ImageSpan.ALIGN_BASELINE);
}
मुझे क्या यू वास्तव में want..provide कोड दिखाने या स्क्रीन शॉर्ट – Destro
@ डेस्ट्रो ने आगे बताया कि मेरा क्या मतलब है। मैंने कोड पोस्ट नहीं किया है क्योंकि मैं कुछ भी विशेष नहीं कर रहा हूं, बस एंड्रॉइड जोड़ रहा हूं: lineSpacingMulitiplier –
छवि जोड़ने के लिए, रैखिक लेआउट या सापेक्ष लेआउट के तहत मतलब है .. छवि लेआउट के ऊर्ध्वाधर में केंद्र में जोड़ दिया गया है। – Destro