J'ai rendu l'arrière-plan de l'application transparent et le style de barre de recherche est ensuite passé du bleu holo d'origine au jaune (voir la photo). L'émulateur Android est défini sur 4.2.2
styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Transparent" parent="@android:style/Theme.Translucent">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:background">@android:color/transparent</item>
</style>
</resources>
Main.axml style de recherche:
<SeekBar
p1:layout_width="250dp"
p1:layout_height="wrap_content"
p1:id="@+id/seekbarLevel"
p1:max="100"
p1:layout_marginRight="10dp"
p1:layout_marginLeft="10dp"
p1:layout_gravity="center" />
1) Comment faire de seekbar utiliser le style standard?
2) Existe-t-il un tutoriel ou quelque chose à propos du formatage ou du style de seekbar et d’autres contrôles? Comment faire d'autres formes et couleurs?
Réponses:
1 pour la réponse № 1Ajoutez le style Halo à votre SeekBar
:
style="@android:style/Widget.Holo.SeekBar"
<SeekBar
android:layout_width="250dp"
android:layout_height="wrap_content"
android:id="@+id/seekbarLevel"
android:max="100"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_gravity="center" />
<SeekBar
android:layout_width="250dp"
android:layout_height="wrap_content"
android:id="@+id/seekbarLevel"
android:max="100"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_gravity="center"
style="@android:style/Widget.Holo.SeekBar" />
1 pour la réponse № 2
Afin de mettre la progression en bleu, essayez ceci dans votre XML sous votre barre de recherche:
android:progressBackgroundTint="@color/Blue"
android:progressTint="@color/Blue"
Et assurez-vous d'ajouter cette ligne à vos chaînes de couleur
<color name="Blue">#0000ff</color> //or whatever variation of blue you want
Voici l'exemple plus complet, y compris comment changer le pouce de la barre de recherche (petit cercle)
<SeekBar
android:id="@+id/blueSeek"
android:layout_width="260dp"
android:layout_height="30dp"
android:layout_marginStart="16dp"
android:colorControlActivated="@color/Blue"
android:max="4096"
android:progress="1800"
android:progressBackgroundTint="@color/Blue"
android:progressTint="@color/Blue"
android:thumbOffset="10dp"
android:thumbTint="@color/Blue"
app:layout_constraintStart_toEndOf="@+id/textView"
app:layout_constraintTop_toBottomOf="@+id/redSeek" />