Reputation: 543
While trying to give ImageSpan
to front of textview
I am getting extra space between the lines on tablet e.g. Nexus 7
But on Nexus5x it's ok
public void setTitleWithItemCount(String name, int itemCount, @StringRes int singularResID, @StringRes int pluralRedID) {
final String itemNoun = itemCount == 1 ? getResources().getString(singularResID) : getResources().getString(pluralRedID);
final String title = getResources().getString(R.string.work_summary_tile_title,
" " + name,
itemCount,
itemNoun);
final SpannableStringBuilder workItemTxt = new SpannableStringBuilder(title);
Drawable d = getResources().getDrawable(actionImage);
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
ImageSpan span = new ImageSpan(d, ImageSpan.ALIGN_BOTTOM);
workItemTxt.setSpan(span, 0, 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
workItemTxt.setSpan(new TextAppearanceSpan(getContext(), R.style.WorkItemTitleText),
1,
name.length(),
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
workItemTxt.setSpan(new TextAppearanceSpan(getContext(), R.style.WorkItemSubTitleText),
name.length(),
title.length() + 1,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
titleView.setText(workItemTxt);
}
xml
<TextView
android:id="@+id/text_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginEnd="5dp"
android:layout_marginStart="-20dp"
android:layout_toEndOf="@+id/image_container"
android:layout_toStartOf="@id/progress_title"
android:ellipsize="end"
android:lines="3"
android:maxLines="3"
android:textAppearance="@style/WorkItemTitleText"
tools:text="@string/lorem_ispum_short"/>
How can I solve this issue?Any help is appreciated
Upvotes: 1
Views: 212
Reputation:
Try one library is used to set value it same all the device. no issue for mange all the device ..
Add below dependency into app level gradle file ..
implementation 'com.intuit.sdp:sdp-android:1.0.4'
then after giving value in this way in all controls..
android:layout_marginStart="@dimen/_75sdp"
android:layout_marginTop="@dimen/_75sdp"
android:padding="@dimen/_15sdp"
Upvotes: 0