use of android.text.style.ImageSpan in project android_frameworks_base by ResurrectionRemix.
the class SearchView method getDecoratedHint.
private CharSequence getDecoratedHint(CharSequence hintText) {
// then don't add the search icon to the hint.
if (!mIconifiedByDefault || mSearchHintIcon == null) {
return hintText;
}
final int textSize = (int) (mSearchSrcTextView.getTextSize() * 1.25);
mSearchHintIcon.setBounds(0, 0, textSize, textSize);
final SpannableStringBuilder ssb = new SpannableStringBuilder(" ");
ssb.setSpan(new ImageSpan(mSearchHintIcon), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ssb.append(hintText);
return ssb;
}
use of android.text.style.ImageSpan in project android_frameworks_base by ResurrectionRemix.
the class RecentsCreateFragment method appendDrawable.
private static void appendDrawable(SpannableStringBuilder b, Drawable d) {
final int length = b.length();
b.append("〉");
b.setSpan(new ImageSpan(d), length, b.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
use of android.text.style.ImageSpan in project UltimateAndroid by cymcsg.
the class PagerTitleStrip method changeSpanString.
// Handler textHandler=new Handler(){
// /**
// * Subclasses must implement this to receive messages.
// *
// * @param msg
// */
// @Override
// public void handleMessage(Message msg) {
// super.handleMessage(msg);
// if (msg.what==1){
// Bundle bundle=msg.getData();
// mCurrText.setText(
// changeSpanString(bundle.getString("string"), bundle.getInt("int"), 1) );
// }else{
// mCurrText.setText(null);
// }
// }
// };
SpannableString changeSpanString(String temp, int position, int color) {
try {
temp = temp.replaceAll("-", " - ");
SpannableString ss = new SpannableString(temp);
Matrix matrix = new Matrix();
matrix.postRotate(180);
Bitmap bitmaporg = BitmapFactory.decodeResource(getResources(), R.drawable.ico_arrow2x);
if (color == 2) {
bitmaporg = BitmapFactory.decodeResource(getResources(), R.drawable.ico_arrow_grey2x);
}
Bitmap resizedBitmap = Bitmap.createBitmap(bitmaporg, 0, 0, bitmaporg.getWidth(), bitmaporg.getHeight(), matrix, true);
BitmapDrawable bmd = new BitmapDrawable(getResources(), resizedBitmap);
BitmapDrawable bm = new BitmapDrawable(getResources(), bitmaporg);
Drawable drawable = position == 0 ? bm : bmd;
drawable.setBounds(0, 0, drawable.getIntrinsicWidth() * 12 / 10, drawable.getIntrinsicHeight() * 12 / 10);
ImageSpan imageSpan = new ImageSpan(drawable, ImageSpan.ALIGN_BASELINE);
ss.setSpan(imageSpan, temp.indexOf("-"), temp.indexOf("-") + 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
return ss;
} catch (Exception e) {
e.printStackTrace();
Logs.e(e, "");
return null;
}
}
use of android.text.style.ImageSpan in project DanmakuFlameMaster by Bilibili.
the class UglyViewCacheStufferSampleActivity method createSpannable.
private SpannableStringBuilder createSpannable(Drawable drawable) {
String text = "bitmap";
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(text);
//ImageSpan.ALIGN_BOTTOM);
ImageSpan span = new ImageSpan(drawable);
spannableStringBuilder.setSpan(span, 0, text.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
spannableStringBuilder.append("图文混排");
spannableStringBuilder.setSpan(new BackgroundColorSpan(Color.parseColor("#8A2233B1")), 0, spannableStringBuilder.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
return spannableStringBuilder;
}
use of android.text.style.ImageSpan in project android_frameworks_base by DirtyUnicorns.
the class RestrictedLockUtils method removeExistingRestrictedSpans.
private static void removeExistingRestrictedSpans(SpannableStringBuilder sb) {
final int length = sb.length();
RestrictedLockImageSpan[] imageSpans = sb.getSpans(length - 1, length, RestrictedLockImageSpan.class);
for (ImageSpan span : imageSpans) {
final int start = sb.getSpanStart(span);
final int end = sb.getSpanEnd(span);
sb.removeSpan(span);
sb.delete(start, end);
}
ForegroundColorSpan[] colorSpans = sb.getSpans(0, length, ForegroundColorSpan.class);
for (ForegroundColorSpan span : colorSpans) {
sb.removeSpan(span);
}
}
Aggregations