2013-06-27 3 views
11

엄지 손가락 이미지가있는 세로선이있는 Google Play 뮤직 앱과 같은 터치 가능한 빠른 스크롤바를 사용하여 목록보기를 맞춤 설정하고 싶습니다. 이 터치 가능한 빠른 스크롤바로 쉽고 빠르게 스크롤 할 수 있습니다. 이 같은 사용자 지정 스크롤바 검색했지만 목록보기에서 빠른 스크롤 막대를 찾을 수 없습니다. 나는 아래의 그림과 같이 스크롤의 출력을 기대하고있다 :맞춤 목록보기 안드로이드의 빠른 스크롤 막대

enter image description here

외부 빠른 스크롤은 빨간 선으로 표시됩니다. StackOverflow에서 this post을 찾았지만 링크의 코드가 예상 출력을 제공하지 않습니다. 이 일을 도와 줄 수 있어요?

+0

수 유 포스트가 UR 코드? – KOTIOS

답변

36

마지막으로 해결책을 찾았습니다. 아래와 같이

  <activity 
      android:name="com.example.viewpager.FirstActivity" 
      android:theme="@style/AppTheme" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 

활동 레이아웃 XML : 그것은 단지

<style name="AppTheme" parent="@style/Theme.Sherlock.Light"> 
     <!-- All customizations that are NOT specific to a particular API-level can go here. --> 
     <item name="android:fastScrollThumbDrawable">@drawable/fast_thumb</item> 
     <item name="android:fastScrollTrackDrawable">@drawable/fastscroll_track_default_holo_dark</item> 

</style> 

코드 아래와 같이이 주제에 대한 활동을 적용 API 레벨 11 이상

값/style.xml와 함께 작동 코드 :

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/rlScrollingPlayList" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/white" 
    android:orientation="vertical" > 

     <ListView 
      android:id="@+id/listView1" 
      android:layout_width="match_parent" 
      android:fastScrollEnabled="true" 
      android:fastScrollAlwaysVisible="true" 
      android:scrollbarStyle="outsideInset" 
      android:layout_height="match_parent" > 
     </ListView> 

</RelativeLayout> 

드로어 블/사진 fast_thumb.xml

최종 출력 아래 그림과 같은

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android" > 

    <item android:state_pressed="true" android:drawable="@drawable/fastscroll_thumb_pressed_holo"/> 
    <item android:drawable="@drawable/fastscroll_thumb_default_holo"></item> 

</selector> 
:

414,자원 이미지 파일

enter image description hereenter image description hereenter here

빠른 스크롤 엄지 선택 XML 파일입니다

enter image description here

+0

누군가가 FastScrollTrackDrawable >> @ null Eftekhari

+0

멋진 답변을 제거해야하는 경우에도 선택기가 제 경우에는 작동하지 않습니다. –

2

때문에 안드로이드 API 레벨 < (11)에 대한 특별한 해킹을

// special hack for violet fast scroll 
     if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { 
      try { 
       java.lang.reflect.Field f = AbsListView.class.getDeclaredField("mFastScroller"); 
       f.setAccessible(true); 
       Object o = f.get(root.findViewById(R.id.beam_contact_listview)); 
       f = f.getType().getDeclaredField("mThumbDrawable"); 
       f.setAccessible(true); 
       Drawable drawable = (Drawable) f.get(o); 
       drawable = getResources().getDrawable(R.drawable.sv_fastscroll); 
       f.set(o, drawable); 
      } catch (Exception e) { 
       e.printStackTrace(); 
      } 
     } 

안드로이드 API 레벨> = 11이 코드 플러스 솔루션 = 모든 안드로이드 API 레벨에 대한 솔루션)

관련 문제