Cómo hacer que EditText se ajuste automáticamente en el desarrollo de software de Android
paquete?com.example.android.helloactivity;
importar?android.content.Context;
importar?android.graphics.Paint;
importar?android.graphics.Rect;
importar?android.text.TextPaint;
importar?android.util.AttributeSet;
importar ?android.View.Display;
importar?android.view.KeyEvent;
¿importar?
importar?p>
público ;clase;MiEditor;extiende;EditarTexto;{
int;screenWidth;=?0;
int;screenHeight;=?0;
int;currentHeight ;=?0;
int;currentHeight;=?
Context?context?=?null;
público?MyEditor(Context?context,?AttributeSet ?atributos)?{
super(contexto,?atributos);
this.context?=?context;
alturaactual?=?getHeight();
WindowManager?windowManager? =?(WindowManager)??this.context
.getSystemService(Context.WINDOW_SERVICE);
Display?display?=?windowManager .getDefaultDisplay();
//Obtener el ancho y alto de la pantalla
screenWidth?=?display.getWidth();
screenHeight?=?display. getHeight ();
setScrollBarStyle(DRAWING_CACHE_QUALITY_AUTO);
/*Rect?getTextBounds("A",?0,?1,?rect);
fontWidth ?=?rect.width();*/
}
@Override
public boolean?onKeyUp(int?keyCode, ?KeyEvent?event? ) ?{
TextPaint?paint?=?getPaint();
float?len?=?paint.measureText(getText().toString());
Calcule cuántas líneas deberían existir actualmente
int? line?=?((int)len?/?screenWidth? ?1);
getEllipsize()?;
setFrame(0,?0,?screenWidth,?line?*?60);
//?setHeight(line*60)?;
//?setMarqueeRepeatLimit (línea)?;
//?setMaxHeight(línea*60)?;
//?setLines(línea)?;
//?setBackgroundColor (Color.BLANCO)?;
¿regresar?