Cómo agregar múltiples textview con imageview en edittext en android
Quiero agregar múltiples textview con imageview en edittext en android. Puedo agregar una textvew con una vista de la imagen en edittext en androide por el código siguiente.
ClickableSpan clickSpan = new ClickableSpan() { @Override public void onClick(View view) { Log.v("clicked", view.getClass().getSimpleName()); // int i = ((EditText) view).getSelectionStart(); // int j = ((EditText) view).getSelectionEnd(); // phoneNum.getText().replace(Math.min(i, j ), // Math.max(i, j ), "", 0, "".length()); } }; final SpannableStringBuilder sb = new SpannableStringBuilder(); TextView tv = createContactTextView(contactname); View view1 = getLayoutInflater().inflate(R.layout.contact_layout,null); TextView tv1 = (TextView) view1.findViewById(R.id.contactName); tv1.setText(contactname); BitmapDrawable bd = (BitmapDrawable) convertViewToDrawable(view1); bd.setBounds(0, 0, bd.getIntrinsicWidth(),bd.getIntrinsicHeight()); sb.append(contactname + ","); sb.setSpan(new ImageSpan(bd), sb.length()-(contactname.length()), sb.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); autoCompleteTextView.setMovementMethod(LinkMovementMethod.getInstance()); sb.setSpan(clickSpan, sb.length(), sb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); autoCompleteTextView.setText(sb); public TextView createContactTextView(String text){ TextView tv = new TextView(this); tv.setText(text); tv.setTextSize(20); tv.setBackgroundResource(R.color.bubble); tv.setCompoundDrawablesWithIntrinsicBounds(0, 0,android.R.drawable.presence_offline, 0); return tv; } public static Object convertViewToDrawable(View view) { int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); view.measure(spec, spec); view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); Bitmap b = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(), Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); c.translate(-view.getScrollX(), -view.getScrollY()); view.draw(c); view.setDrawingCacheEnabled(true); Bitmap cacheBmp = view.getDrawingCache(); Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888, true); view.destroyDrawingCache(); return new BitmapDrawable(viewBmp); }
Por el código anterior tengo la siguiente disposición.
- AppCompat v22: Establecer el color de texto predeterminado para TextView
- 2 colores diferentes para texto en la misma vista de texto en android
- ¿Hay una manera de hacer ellipsize = "marquee" siempre desplazarse?
- Establecer el borde y el color de fondo de textView
- Detectar si TextView en ListView está ellipsizado
¿Cómo puedo agregar múltiples textview con imageview como el siguiente diseño?
He hecho esto con autocompletetextview. Después de insertar una vista de texto con la vista de imagen, se detiene la sugerencia de autocompletetextview. ¿Cómo puedo iniciar la auto-sugerencia de autocompletetextview de nuevo? ¿Cómo puedo insertar múltiples textview con imageview en autocompletetextview?
2
- ¿Cómo encontrar el número de caracteres de TextView de Android por línea?
- Establecer texto temporal en un EditText / TextView en Android?
- ¿Cómo auto-ajustar el tamaño del texto en un TextView multi-línea de acuerdo con la vista de las dimensiones máximas?
- Actualizar un TextView después de hacer clic en el botón?
- ¿Cuál es una buena manera de limitar el número de palabras que se pueden introducir en una vista de edición de Android?
- ¿Cómo se desplaza el texto con el buscador?
- Centrar el contenido de TextView vertical y horizontalmente - LinearLayout
- Añadir opaco "sombra" (esquema) a Android TextView
- Desplácese nestedscrollview para finalizar antes de que los rollos de reciclerview para niños
- La vista previa de la cámara es negra cuando se utiliza getExternalStorageDirectory para guardar el vídeo