Programación y Desarrollo para Android Subforo exclusivo para temas de programación de software para PDAs y desarrollo de aplicaciones, interfaces, etc bajo Android


 
Herramientas
  #1  
Viejo 20/08/10, 12:55:45
Avatar de theabdabs
theabdabs theabdabs no está en línea
Miembro del foro
Mensajes: 71
 
Fecha de registro: ago 2009
Mensajes: 71
Modelo de smartphone: HTC Desire
Mencionado: 0 comentarios
Tagged: 0 hilos
Tamaño Seekbar en preferences

Hola,

estoy intentando crear un widget de preferences para poder establecer un valor con la Seekbar.
Esto incluye un Title, un Summary, la Seekbar y un TextView para mostrar el valor. Salvo el Title todo sale en la segunda lína.

El tema es que no he conseguido que se muestre bien. Primero probé con un RelativeLayout y no hacía caso de los Rules BELOW, etc. Así que me pasé a los LinearLayouts + TableLayout pero la seekbar no me coge el tamaño mínimo y queda pequeña.



Lo creo por código. Alguien sabe cómo hacer que me haga caso?

Código:
      
    LinearLayout layoutv = new LinearLayout(getContext());
    layoutv.setOrientation(LinearLayout.VERTICAL);
    
    //Title
    LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, 
            LinearLayout.LayoutParams.WRAP_CONTENT);
    TextView view = new TextView(getContext());
    view.setId(VIEW_ID_TITLE);
    view.setText(getTitle());
    view.setTextSize(21);
    view.setTypeface(Typeface.SANS_SERIF, Typeface.NORMAL);
    view.setTextColor(Color.WHITE);
    view.setLayoutParams(params1);
    layoutv.addView(view);

    //TAble Layout to show all the information
    TableLayout layout = new TableLayout(getContext());

    TableLayout.LayoutParams params0 = new TableLayout.LayoutParams(
            TableLayout.LayoutParams.FILL_PARENT, 
            TableLayout.LayoutParams.WRAP_CONTENT);
    layout.setLayoutParams(params0);
    layout.setShrinkAllColumns(true);
    
    //Row
    TableRow tr = new TableRow(getContext());
    
    //Summary
    TextView summary = new TextView(getContext());
    summary.setId(VIEW_ID_SUMMARY);
    summary.setText(getSummary());
    summary.setTextSize(14);
    summary.setTypeface(Typeface.SANS_SERIF, Typeface.NORMAL);
    tr.addView(summary);

    //SeekBar
    SeekBar bar = new SeekBar(getContext());
    bar.setId(VIEW_ID_BAR);
    bar.setMax(maximum);
    bar.setProgress((int)this.oldValue);
    bar.setMinimumWidth(80);
    bar.setOnSeekBarChangeListener(this);
    tr.addView(bar);
       
    //Monitor Box
    this.monitorBox = new TextView(getContext());
    this.monitorBox.setId(VIEW_ID_MONITOR);
    this.monitorBox.setTextSize(12);
    this.monitorBox.setTypeface(Typeface.MONOSPACE, Typeface.ITALIC);
    this.monitorBox.setPadding(2, 5, 0, 0);
    this.monitorBox.setText(Float.toString((float) bar.getProgress()/10.0f));
    tr.addView(this.monitorBox);       

    layout.addView(tr);
    
   layoutv.setPadding(15, 5, 10, 5);  

   layoutv.addView(layout);
   
   layoutv.setId(android.R.id.widget_frame);

   return layoutv;
Gracias
Responder Con Cita


Respuesta

Estás aquí
Regresar   HTCMania > Todo sobre Android > Programación y Desarrollo para Android


Reglas de Mensajes
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Las caritas están On
Código [IMG] está On
Código HTML está Off

Saltar a Foro



Hora actual: 13:17:14 (GMT +1)

Cookies settings
Powered by vBulletin™
Copyright © vBulletin Solutions, Inc. All rights reserved.
 
HTCMania: líderes desde el 2007