【问题标题】:SeekBar doesn't correct show progressDrawableSeekBar 不正确显示 progressDrawable
【发布时间】:2015-07-06 12:04:05
【问题描述】:

对不起我的英语。我尝试使用自定义 SeekBar,但它的 SeekBar 无法正确显示 progressDrawable。图一是我的进步:

如果我的值很大,progressDrawable 看起来像这样

我的xml

 <SeekBar
                                android:id="@+id/seekBarHome"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:paddingTop="10dp"
                                android:paddingBottom="20dp"
                                android:paddingLeft="0dp"
                                android:paddingRight="20dp"
                                android:progressDrawable="@drawable/thumbler_small"
                                android:max="50"
                                android:thumb="@mipmap/men"
                                android:layout_centerVertical="true"
                                android:layout_alignParentLeft="true"
                                android:layout_alignParentStart="true" />

thumbler_small

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:id="@android:id/background"
        android:drawable="@drawable/seek_bar_background"/>
    <item android:id="@android:id/progress"
        android:drawable="@drawable/seek_bar_progress" />
</layer-list>

【问题讨论】:

    标签: android xml seekbar


    【解决方案1】:

    看起来包含您的SeekBar 的父布局不够宽,无法容纳自定义可绘制宽度。尝试确保父布局比SeekBar 宽至少两侧自定义可绘制对象的直径。此外,请确保您没有使用边距或填充来限制它的宽度,而是将其置于父布局的中心,以便在侧面留下额外的空间以完全显示您的可绘制对象。最简单的方法是将SeekBars 的宽度设置为小于其父级的宽度,以您的可绘制对象的直径为准,看看它是否能解决您的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-05
      • 2020-10-30
      相关资源
      最近更新 更多