android - SeekBar progressDrawable fitXY
问题描述
我有一个带有progressDrawable 的SeekBar。
<SeekBar
android:id="@+id/seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:progress="50"
android:progressDrawable="@drawable/image"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
在这个搜索栏中,我使用了 image.png
我的手机屏幕比这张图大。所以我想像“fitXY”一样使用这个图像。
如何将图像设置为 match_parent?
谢谢 !
解决方案
试试这个
<SeekBar
android:id="@+id/seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:progress="50"
android:progressDrawable="@drawable/seekbar_bg"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Drawble 文件夹 seekbar_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:left="300dip">
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#0000FF" />
</shape>
</item>
<item android:right="400dip">
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#ff0000" />
</shape>
</item>
</layer-list>
推荐阅读
- c++ - 在 C++ 中,您可以像比较类型一样比较模板吗?
- javascript - SyntaxError:带有 mocha 和 babel 的意外标识符
- linux - 在特定位置获取单词后的文本
- php - 用户创建给了我不正确的 ID 值
- java - 找不到调用两个点到一个方法的麻烦。“Java - 距离点”
- python-3.x - python 上的辛普森集成
- ruby-on-rails - Ruby on Rails 语法错误,意外的输入结束,期望关键字_end end ^
- angularjs - ANGULARJS:未捕获的错误:语法错误,无法识别的表达式:#!/
- android - 在 Sugar 中执行 sql 查询时显示异常
- rest - 在 SharePoint 页面上使用 rest api 从 iserver 获取数据