2017-05-16 8 views
0

私はシークバーを持っていますが、小さなサークルの親指のものはつかむのが難しいです。ヒットボックスを大きくする方法はありますか?私はグラフィック自体が異なって見えるかどうか私は必ずしも気にしない - 私はそれをgrabbableしたい。シークバーのつまみをつかみやすくする

答えて

1

あなたは親指の大きさを変化させることにより、Andrewによって回答シークバーを、カスタマイズすることができます。

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 
<item> 
    <shape> 
     <size 
      android:height="40dp" 
      android:width="40dp" /> 

     <solid android:color="@android:color/transparent" /> 
    </shape> 
</item> 
<item android:drawable="@drawable/scrubber_control_normal_holo"/> 
</layer-list> 

thumb_image.xmlプレースホルダとしての形状を有する層状絞り可能を作成する例を以下に結果を示します。

<SeekBar 
android:id="@+id/seekBar1" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:thumb="@drawable/thumb_image" /> 

Thumbカスタマイズのもう1つの良い例です。

+0

私はその解決策を試みましたが、 "scrubber_control_normal_holo"を見つけることができませんでした – KaliMa

+0

必要なリソースはhttp://android-holo-colors.com/からダウンロードして、Drawableフォルダに追加してください。 –

+0

@KaliMaこれはscrubber_control_normal_holo.pngイメージ名です。シンプルで小さな円のアイコンを使ってscrubber_control_normal_holoという名前をつけてドロアブルに入れて、上記の例を使用すると答えが出ます。それがあなたの問題を解決したら、それを答えさせてください。 –

0

はシークバーDiscreteSeekBarため

をこのクールなライブラリをチェックアウトし、同様に、以下の属性があり、次の

<org.adw.library.widgets.discreteseekbar.DiscreteSeekBar 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:dsb_min="2" 
     app:dsb_max="15" 
/> 

により多くの複雑させずに追加することができます。図書館で

dsb_progressColor: color/colorStateList for the progress bar and thumb drawable 
dsb_trackColor: color/colorStateList for the track drawable 
dsb_indicatorTextAppearance: TextAppearance for the bubble indicator 
dsb_indicatorColor: color/colorStateList for the bubble shaped drawable 
dsb_indicatorElevation: related to android:elevation. Will only be used on API level 21+ 
dsb_rippleColor: color/colorStateList for the ripple drawable seen when pressing the thumb. (Yes, it does a kind of "ripple" on API levels lower than 21 and a real RippleDrawable for 21+. 
dsb_trackHeight: dimension for the height of the track drawable. 
dsb_scrubberHeight: dimension for the height of the scrubber (selected area) drawable. 
dsb_thumbSize: dimension for the size of the thumb drawable. 
dsb_indicatorSeparation: dimension for the vertical distance from the thumb to the indicator. 

その他のSeekBarコンポーネントはthese

0

埋め込み可能な描画可能リソースが必要です。 「ShapeDrawable内のオフセットシェイプ」https://stackoverflow.com/a/3674134/3175580という質問に対するこの回答は、同じことが起こります。他の答えと同じように、ターゲットドロアブルがプライベートであればコピーする必要があります。

利点(または欠点)は、合計サイズではなくサイズをどれだけ増やしているかを正確に示していることです。さらに、透明なシェイプを使用すると、そのサイズの透明なビットマップ(?)が作成されるため、メモリが節約されると思います。

関連する問題