엄지 클리핑과 관련된 많은 stackoverflow 질문은 내 질문과 관련이없는 왼쪽 및 오른쪽 클리핑과 관련이 있습니다.동적으로 크기가 조정 된 SeekBar의 Thumb이 위아래로 잘린 채 어떻게 맨 위 (Z 순서)에 그리는가?
엄지 손가락은 이미지입니다. SeekBar 슬라이드가 오른쪽으로 확대 될 때 이미지 크기가 onProgressChanged로 재설정됩니다.
문제는 SeekBar보기의 상단을 터치 할만큼 이미지의 키가 커지면 상단이 맨 위에 닿으면서 이미지의 크기가 계속 조정됩니다. 시각적으로 엄지 이미지가 페이지 아래로 이동하는 것처럼 보입니다.
원하는 것은 (1) 이미지가 오른쪽으로 밀려서 이미지가 막대 중앙에 오도록하는 것입니다. (2) SeekBar 뷰 내부에서 클리핑 된 것이 아닌 모든 것의 TOP에 그려 질 엄지 이미지.
SeekBar 뷰와 함께 bringToFront()를 시도했지만 아무 것도 변경하지 않았습니다.
번호 :
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 파라미터 (안드로이드 :의 maxHeight = "1000dp")는 수직 검색 막대를 중심으로하여 이미지를 유지할 수있는 대안이다
<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.