2010-05-11 7 views
2

J'utilise une barre de recherche dans mon application Android pour régler le volume. Cependant, la longueur de la barre de recherche est trop courte. Alors, y a-t-il un moyen de personnaliser la longueur d'une barre de recherche?Manipulation de longueur de barre de recherche

+0

Veuillez poster votre mise en page XML. –

Répondre

0
SeekBar sk =(SeekBar)findViewById(R.id.seekbar); 
sk.setLayoutParams(params) 

L'utilisation de ce que vous pouvez régler la longueur de la barre de recherche

2

exemple XML:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:padding="10dip"> 
<SeekBar android:id="@+id/default_width_seek_bar" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" /> 
<SeekBar android:id="@+id/fixed_width_seek_bar" 
    android:layout_width="100dip" 
    android:layout_height="wrap_content" /> 
<SeekBar android:id="@+id/full_width_seek_bar" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" /> 
<SeekBar android:id="@+id/padded_full_width_seek_bar" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:paddingLeft="8dip" android:paddingRight="8dip" /> 
</LinearLayout> 

Side note: peut clipser Le pouce de la barre de recherche quand il est déplacé tout le chemin à la côtés. Un petit rembourrage supplémentaire comme dans le dernier SeekBar résout ce problème.

Questions connexes