2017-04-21 7 views
8

मुझे लगता है कि के लिए छवि
enter image description hereकस्टम seekbar एंड्रॉयड

enter image description here

नीचे की तरह के रूप में कस्टम seekbar प्राप्त करने के लिए कोशिश कर रहा हूँ मुझे लगता है मैं seekbar progressDrawable के लिए drawable बनाया है
नीचे कोड मुझे अगर कोड पता है था आवश्यक है, मैं इसे यहां पोस्ट करूंगा।

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout android:id="@+id/llScale" 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:orientation="vertical" 
      android:paddingBottom="5dp"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/white" 
    android:orientation="vertical" 
    android:padding="5dp"> 

    <TextView 
     android:id="@+id/sliderText" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:padding="5dp" 
     android:text="Bernard" 
     android:textColor="@color/blue"/> 

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:background="@drawable/slider_background" 
      android:padding="3dp"> 

      <SeekBar 
       android:id="@+id/ratingBar" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:max="10" 
       android:maxHeight="100dp" 
       android:thumbTintMode="multiply" 
       android:progressDrawable="@drawable/progressbar" 
       android:thumb="@drawable/ic_slider_secondary"/> 

      <TextView 
       android:id="@+id/seekBarHint" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:gravity="center" 
       android:text="Drag slider across" 
       android:textColor="@color/dark_gray"/> 
     </FrameLayout> 

     <TextView 
      android:id="@+id/progressText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@drawable/ic_slider_progress" 
      android:gravity="center" 
      android:textColor="@color/white" 
      android:textStyle="bold"/> 
    </FrameLayout> 
</LinearLayout> 

लेकिन इसके बाद के संस्करण कोड है कि मैं क्या हो रही है छवि
प्रकाश लाल रंग पूरी तरह से नहीं भरा जा रहा है नीचे के रूप में है के साथ, यह कुछ जगह lefts और अंत सर्कल पर boundries से बाहर चला जाता है।

enter image description here

enter image description here

Gradle

compileSdkVersion 23 
buildToolsVersion "23.0.2" 
defaultConfig { 
    applicationId "com.myapp" 
    minSdkVersion 16 
    targetSdkVersion 23 
    multiDexEnabled true 
    versionCode 1 
    versionName "1.0" 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
} 

किसी कृपया मुझे इस

+0

क्या आप की जरूरत एक कस्टम प्रगति 'Drawable' है, तो आप इसे बुला' seekbar # setProgressDrawable (Drawable घ) द्वारा निर्धारित कर सकते हैं ' – pskink

+0

@pskink: मैं निर्धारित किया है यह एक्सएमएल एंड्रॉइड में: progressDrawable = "@ drawable/progressbar" –

उत्तर

3

मैं अपने कोड का इस्तेमाल किया और बनाया डेमो जिसमें मैं 2 परिवर्तन के रूप में नीचे किया साथ मदद कर सकते हैं :

  1. मेरे लिए उचित मूल्य के साथ अंगूठे ऑफसेट सेट करें 16.5 डीपी काम किया।

  2. एक और संपत्ति जोड़ें एंड्रॉइड जोड़ें: splitTrack = "false" जो अंगूठे के आसपास की जगह को हटाने में मदद करेगा।

    <SeekBar 
        android:id="@+id/ratingBar" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:maxHeight="100dp" 
        android:progressDrawable="@drawable/progressbar" 
        android:thumb="@drawable/ic_slider_secondary" 
        android:splitTrack="false" 
        android:thumbOffset="16.5dp"/> 
    

मुबारक कोडिंग :)

+0

धन्यवाद बहुत दोस्त। :) –

संबंधित मुद्दे