1

私はカスタムシークバーのサムを作成しました。アンドロイドのスタジオのプレビューでは非常によく見えますが、デバイス上でアプリを実行すると間違っています。Androidのシークバーのサムのドロウアブルが正しく表示されない

それは実際に私のデバイス what it actually look like on my device

私seekbar_thumb.xmlコード

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 
<item android:height="35dp" android:width="35dp" > 
    <shape android:shape="oval"> 
     <solid android:color="#fff" /> 
    </shape> 
</item> 
<item android:gravity="center" android:height="15dp" android:width="15dp"> 
    <shape android:shape="oval"> 
     <solid android:color="@color/colorPrimary" /> 
    </shape> 
</item> 

私のシークバーコード

を上のように見えるものを what it should look like

どのように見えますか

 <SeekBar 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/seekBar" 
     android:max="100" 
     android:progress="50" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentRight="true" 
     android:layout_centerInParent="true" 
     android:thumb="@drawable/seekbar_thumb" 
     android:progressDrawable="@drawable/progress_bar_background" 
     android:layout_marginBottom="@dimen/seekbar_margin_bottom" 
     android:layout_marginRight="@dimen/seekbar_margin_rt" 
     android:layout_marginLeft="@dimen/seekbar_margin_lt" 
     android:thumbOffset="0dp"/> 

答えて

1

は偉大な作業を描画可能なフォルダに

<?xml version="1.0" encoding="utf-8"?> 
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item> 
    <shape android:shape="oval"> 
    <solid android:color="#00f"/> 
    <size 
    android:width="15dp" 
    android:height="15dp"/> 
    </shape> 
    </item> 
    <item> 
    <shape android:shape="oval"> 
    <stroke android:color="@android:color/transparent" 
    android:width="5dp"/> 
    <solid android:color="#f00"/> 
    <size 
    android:width="10dp" 
    android:height="10dp"/> 
    </shape> 
    </item> 
    </layer-list> 

そしてactivity_main.xml

<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:orientation="vertical" 
    android:layout_margin="40dp"> 

    <SeekBar 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/seekBar" 
    android:max="100" 
    android:progress="50" 
    android:thumb="@drawable/seekbar_thumb" /> 

    </RelativeLayout> 
+0

このseekbar_thumb.xmlをお試しください!なぜこれがうまくいったのか説明してもらえますか?最初のものはどうでしたか? – Bialy

+0

に高さと幅を定義しなければなりません。に直接は入っていません。また、もっと小さな半径の円を描き、次のようにして単色にしてください:

+0

のすべての高さと幅のパラメータを定義すると、 アンドロイド:高さ= "10dp" />あなたのコードは、アンドロイド6のデバイスでうまく機能しますが、下位デバイスではが重要です –