Ich benutze this basic wrapper um eine SeekBar herum, aber finde, dass es den Daumen versteckt, oder macht etwas Funky wie machen es weiß auf weißem Hintergrund, unter Marshmallow.Android 6.0 Marshmallow hört auf zu zeigen Vertical SeekBar thumb
Ich habe den AS "BlankActivity" -Assistenten verwendet, um ein Projekt zu erstellen, um dies zu illustrieren, wobei nichts außer den hier beschriebenen von den Standardeinstellungen geändert wird. Auf der linken Seite ist Lollipop, und der gleiche Code auf der rechten Seite unter Eibisch ausgeführt wird:
Es ist eine eigene horizontale SeekBar zu testen, ob es ein generelles Problem Customizing sie war, was es nicht ist. Die erste vertikale links hat keinen Stil, was ein guter Vor-Marshmallow ist, aber sonst nicht, die zentrale Explility verwendet den Widget.Material.Light.SeekBar Stil, um zu testen, ob der Standard irgendwie nicht aufgenommen wurde, und der das letzte gibt einen großen Hinweis, weil es den alten Widget.Holo.SeekBar Stil verwendet, wo es dann erscheint, obwohl es aussieht, als ob es vor ein paar Jahren herauskam.
Hier ist das Layout für diese:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
>
<com.otamate.seekbarmarshbug.CustomSeekBar
android:id="@+id/seekBarCustom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<com.otamate.seekbarmarshbug.VerticalSeekBar
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="@+id/seekBarCustom"
/>
<com.otamate.seekbarmarshbug.VerticalSeekBar
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:layout_below="@+id/seekBarCustom"
android:layout_centerHorizontal="true"
style="@android:style/Widget.Material.Light.SeekBar"
/>
<com.otamate.seekbarmarshbug.VerticalSeekBar
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_below="@+id/seekBarCustom"
style="@android:style/Widget.Holo.SeekBar"
/>
</RelativeLayout>
Die CustomSeekBar:
package com.otamate.seekbarmarshbug;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.SeekBar;
public class CustomSeekBar extends SeekBar {
public CustomSeekBar(Context context) {
super(context);
}
public CustomSeekBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public CustomSeekBar(Context context, AttributeSet attrs) {
super(context, attrs);
}
}
und die VerticalSeekBar:
package com.otamate.seekbarmarshbug;
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.SeekBar;
public class VerticalSeekBar extends SeekBar {
public VerticalSeekBar(Context context) {
super(context);
}
public VerticalSeekBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public VerticalSeekBar(Context context, AttributeSet attrs) {
super(context, attrs);
}
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(h, w, oldh, oldw);
}
@Override
protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(heightMeasureSpec, widthMeasureSpec);
setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
}
protected void onDraw(Canvas c) {
c.rotate(-90);
c.translate(-getHeight(), 0);
super.onDraw(c);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!isEnabled()) {
return false;
}
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE:
case MotionEvent.ACTION_UP:
setProgress(getMax() - (int) (getMax() * event.getY()/getHeight()));
onSizeChanged(getWidth(), getHeight(), 0, 0);
break;
case MotionEvent.ACTION_CANCEL:
break;
}
return true;
}
}
Dieser Fehler mit M arbeitet, ist * fast * in com.android.support:appcompat-v7:23.1.0 fixiert. Damit sieht der Daumen genauso aus wie der horizontale mit dem Code, wie er hier dargestellt wird, nur gibt es keine Animation, wenn er ausgewählt und bewegt wird (die groovige "Beule und sich ausdehnende Welle", die kurz von seinem Rand aufblitzt) Sehen Sie den langweiligen aber funktionalen Kreis. –
mit appcompat-v7: 23.1.1 hier. Der Daumen ist auf Marshmallow völlig unsichtbar. Beendet die Erstellung eines benutzerdefinierten Thumbs, der gut funktioniert. – Matthias