Ich möchte die Suchleiste an meine Bedürfnisse anpassen:Ich möchte eine Kunden-Suchleiste wie unten beschrieben definieren, aber wie?
Der Daumen kann nur an vier festen Ort platziert werden. Wenn ich zum Beispiel die maximale Eigenschaft der Suchleiste auf 120 setze, ist die vier feste Position 0, 40, 80 120. Außerdem möchte ich Indikatoren haben, die den Leuten die Mittel des aktuell ausgewählten Standorts mitteilen. so mache ich es wie folgt:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/ll_id"
android:paddingLeft="10dp">
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="small"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="middle"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/tv3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="big"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/tv4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="extrabig"/>
</LinearLayout>
<SeekBar android:id="@+id/sk"
android:layout_below="@+id/ll_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="120"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:layout_marginRight="0dp"/>
</RelativeLayout>
public class CustomSeekBar extends FrameLayout {
private SeekBar sk;
private OnWhichSelected selected;
public CustomSeekBar(Context context) {
this(context, null);
}
public CustomSeekBar(Context context, AttributeSet attrs) {
super(context, attrs);
LayoutInflater.from(context).inflate(R.layout.customseekbar_layout, this, true);
sk = (SeekBar) this.findViewById(R.id.sk);
sk.setProgress(0);
callbackhelp(Which.SMALL);
sk.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// TODO Auto-generated method stub
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
int seekProgress = seekBar.getProgress();
if(seekProgress<seekBar.getMax()/6){
callbackhelp(Which.SMALL);
seekBar.setProgress(0);
}else if(seekProgress>=seekBar.getMax()/6 && seekProgress<3*(seekBar.getMax()/6)){
callbackhelp(Which.MIDDLE);
seekBar.setProgress(seekBar.getMax()/3);
}else if(seekProgress>=3*(seekBar.getMax()/6) && seekProgress<5*(seekBar.getMax()/6)){
callbackhelp(Which.LARGE);
seekBar.setProgress(4*(seekBar.getMax()/6));
}else if(seekProgress>=5*(seekBar.getMax()/6)){
callbackhelp(Which.EX_LARGE);
seekBar.setProgress(seekBar.getMax());
}
}
});
}
private void callbackhelp(Which which){
if(selected!=null){
selected.onSeleted(which);
}
}
public enum Which{
SMALL,
MIDDLE,
LARGE,
EX_LARGE
}
public interface OnWhichSelected{
void onSeleted(Which which);
}
}
nun das Ergebnis ist wie folgt:
das Ergebnis
Sie die Daumen sehen nicht Zentrum unter der „Mitte“ Anzeige ausrichten, wie man Behebung, dass der Daumen unter jedem Indikator auf verschiedenen Geräten zentriert werden kann? Danke
jemand mir helfen? danke –