2013-01-24 4 views
1

현재 xml을 배경 이미지로 사용하지 않고 사용자 지정 Seekbar를 만들려고하고 있으며 진행률 표시 줄을 변경해야합니다. 이것은 내가 지금 무엇을 가지고 :프로그래밍 방식으로 사용자 지정 탐색 모음 만들기 (XML 없음)

Drawable drawable = new BitmapDrawable(appState.images.get(Integer.parseInt(image))); 
this.setBackgroundDrawable(drawable); 

Drawable drawable2 = new BitmapDrawable(appState.images.get(Integer.parseInt(image_a)));  
this.setProgressDrawable(drawable2); 

this.setProgress(0); 

그러나 progressDrawable 단지 SeekBar를 전체 크기로 설정하고 내가 좌우로 엄지 손가락을 이동할 때 아무 반응이 없습니다. 내가 완전히 엉망이 된 것처럼 아무도 어떤 생각을 가지고 있지 않습니까.

+0

런타임시 또는 표준에서 그래픽을 변경해야합니까? – anthropomo

+0

이미지를 다운로드하고 저장 한 다음 런타임에보기를 표시 할 때 변경해야합니다. – Marche101

+0

내가 사용하는 사용자 정의 seekbar XML 처리 drawable 주위에 "클립"태그를 사용합니다. 나는 그것이 어떻게 작동하는지 정확히 모르겠다. 그러나 나는 그것없이 seekbar 오작동을 안다. clipDrawable 프로그래밍 방식으로 얻을 수 있다고 생각합니다. 나는 한번 볼게. 참고로, 여기 내 XML은 다음과 같습니다 '<항목 \t \t 안드로이드 : ID = "@ 안드로이드 : ID/진행 상황을"> \t \t \t \t \t \t \t \t <고체 \t \t \t 안드로이드 : 색상 = "@ 색상/하이라이트"/> \t \t \t \t \t \t ' – anthropomo

답변

4

그래서이 이전의 대답은 당신을 위해 트릭을 수행합니다 결국

나는이 코드를 사용하고 있습니다 :

public void setSeekBarImages(){ 
    Drawable drawable = new 
      BitmapDrawable(appState.images.get(Integer.parseInt(image_a))); 
    ClipDrawable clip = new ClipDrawable(drawable, 
      Gravity.LEFT,ClipDrawable.HORIZONTAL); 
    Drawable drawable2 = new 
      BitmapDrawable(appState.images.get(Integer.parseInt(image))); 
    InsetDrawable d1= new InsetDrawable(drawable2,5,5,5,5); 
    //the padding u want to use 
    setThumb(null); 
    LayerDrawable mylayer = new LayerDrawable(new Drawable[]{d1,clip}); 
    setProgressDrawable(mylayer); 
    setProgress(0); 
} 
을 원래 아스 커에서

Changing the size of the seekbar programmatically but cant get the thumb to be larger than the bar

관련 문제