Многие вопросы о stackoverflow, связанные с отсечением большого пальца, связаны с отсечением влево и вправо, что не связано с моим вопросом.динамически измененный размер Thumb of SeekBar получает обрезанный сверху и снизу, как рисовать сверху (заказ Z)?
Thumb - изображение. Масштаб изображения сбрасывается на ProProcessChanged, чтобы масштабироваться, так как слайды SeekBar правы.
Проблема заключается в том, что, когда изображение становится достаточно высоким, чтобы коснуться верхней части изображения SeekBar, изображение продолжает масштабироваться, сохраняя верхний касание вершины. Поэтому визуально это выглядит так, как изображение большого пальца движется вниз по странице.
Желательно, чтобы (1) изображение оставалось центрированным на панели, так как изображение сдвинуто вправо. (2) изображение большого пальца, которое будет нарисовано поверх всех, а не обрезано внутри вида SeekBar.
Я попытался принестиToFront() с видом SeekBar, но это ничего не меняет.
коды:
SeekBar.OnSeekBarChangeListener sbcl = new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekbar, int i, boolean b) {
Resources res = getResources();
int resID = (Integer)seekbar.getTag();
// Log.i("R vals in Listener :"," "+resID);
Drawable thumb = res.getDrawable(resID);
double h = (double)thumb.getIntrinsicHeight();
double w = (double)thumb.getIntrinsicWidth();
double di = (double)i;
h = h * 0.2; //scale for icons that are way to big
w = w * 0.2;
Log.i("seek 2"," h: "+h+" w: "+ w);
w = w * (di/200 + 0.5);
h = h * (di/200 + 0.5);
Log.i("seek 3"," h: "+h+" w: "+ w +" i: "+ i);
if (w<1) {w = 1;} if (h<1) {h = 1;}
Bitmap bmpOrg = ((BitmapDrawable)thumb).getBitmap();
Bitmap bmpScaled = Bitmap.createScaledBitmap(bmpOrg, (int)w, (int)h, true);
Drawable newThumb = new BitmapDrawable(res, bmpScaled);
newThumb.setBounds(0, 0, newThumb.getIntrinsicWidth(), newThumb.getIntrinsicHeight());
seekbar.setThumb(newThumb);
}
XML-разметки параметр MaxHeight (Android: MaxHeight = "1000dp") обходной путь, чтобы сохранить изображение вертикально по центру SeekBar
<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="sic.emo.apptt.GetProtectorData$PlaceholderFragment">
<sic.eco.appt.VerticalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="vertical"
android:layout_weight="1">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="100dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/LabelSA"
android:layout_gravity="center"
android:id="@+id/textLabelSA" />
<SeekBar
android:layout_width="match_parent"
android:layout_height="80dp"
android:id="@+id/seekBarPS"
android:thumb="@drawable/dog"
android:maxHeight="1000dp"
android:hapticFeedbackEnabled="true"
android:layout_gravity="center_horizontal" />
</LinearLayout>
etc. etc.