更改默认的seekbar颜色
问题描述:
如果有人知道我在做什么错误,请让我知道。 我创建了一个android应用程序,我试图将seekbar的默认颜色从黄色更改为任何其他颜色。我创建了一个位于所有3个drawable中的xml文件并运行该项目,但seekbar的颜色仍然不会改变颜色。 下面是代码我和一个来自irc的同伴一直在努力。更改默认的seekbar颜色
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="#ff9d9e9d"
android:centerColor="#ff5a5d5a"
android:centerY="0.75"
android:endColor="#ff747674"
android:angle="270"
/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="#80ffd300"
android:centerColor="#80ffb600"
android:centerY="0.75"
android:endColor="#a0ffcb00"
android:angle="270"
/>
</shape>
</clip>
</item>
<item
android:id="@android:id/progress"
>
<clip>
<shape>
<corners
android:radius="5dip" />
<gradient
android:startColor="#FF0000"
android:centerColor="#FF0000"
android:centerY="0.75"
android:endColor="#FF0000"
android:angle="270" />
</shape>
</clip>
</item>
</layer-list>
这是我的Java代码
SeekBar seekBar = (SeekBar)findViewById(R.id.seekbar);
final TextView seekBarValue = (TextView) findViewById(R.id.seekbarvalue); //filling seekbar
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
{
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
{
seekBarValue.setText(String.valueOf(progress+1998)); //sets the date to seekBar when in motion
}
@Override
public void onStartTrackingTouch(SeekBar seekBar)
{
//TO DO Auto-Generated Method stub
}
@Override
public void onStopTrackingTouch(SeekBar seekBar)
{
//TO DO Auto-Generated Method stub
}
答
好了,所以基本上所有我需要做的是进入我的main.xml文件不位于绘项目文件夹中的一个,然后确保把
android:progressDrawable="@drawable/myprogress"
其中myprogress是位于drawables文件夹中的.xml文件的名称。
这不显示使用XML的位置。请在线程中发布相关代码 – Blundell 2011-03-15 16:12:42
请编辑您的问题(不要开始第三个问题),并显示您使用此drawable来自定义您的“SeekBar”。 – CommonsWare 2011-03-15 17:38:52
[更改黄色默认seekbar颜色]的可能的重复。(http://stackoverflow.com/questions/5315641/changing-yellow-default-seekbar-color) – msarchet 2011-03-15 18:00:46