Android Roboto, , , , ( ). , "" - .
, : .
Drawable (ic_arrow.xml) res/drawable :
<vector android:alpha="0.78" android:height="24dp"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M3,12L21.5,12"
android:strokeColor="#000000" android:strokeWidth="1"/>
<path android:fillColor="#FF000000" android:pathData="M21,12L17,8"
android:strokeColor="#000000" android:strokeWidth="1"/>
<path android:fillColor="#FF000000" android:pathData="M21,12L17,16"
android:strokeColor="#000000" android:strokeWidth="1"/>
</vector>
SpannableString, TextView. ( ) , :
Drawable, , .
Drawable arrow = ContextCompat.getDrawable(this, R.drawable.ic_arrow);
, .
Float ascent = textView.getPaint().getFontMetrics().ascent;
( ), .
int h = (int) -ascent;
, Drawable
.
arrow.setBounds(0,0,h,h);
SpannableString, . * , ( ). , SpannableStringBuilder.
SpannableString stringWithImage = new SpannableString("A*B");
, , (
ImageSpan "", ).
1 2 (
), SPAN_EXCLUSIVE_EXCLUSIVE ,
span , .
stringWithImage.setSpan(new ImageSpan(arrow, DynamicDrawableSpan.ALIGN_BASELINE), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
, ( ):
textView.setText(stringWithImage);
.
TextView textView = findViewById(R.id.my_text_view);
Drawable arrow = ContextCompat.getDrawable(this, R.drawable.ic_arrow);
Float ascent = textView.getPaint().getFontMetrics().ascent;
int h = (int) -ascent;
arrow.setBounds(0,0,h,h);
SpannableString stringWithImage = new SpannableString("A*B");
stringWithImage.setSpan(new ImageSpan(arrow, DynamicDrawableSpan.ALIGN_BASELINE), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.setText(stringWithImage);
, Android , -. TextView :
