更改默认搜索栏颜色
如果有人知道我做错了什么,请告诉我。 我创建了一个 Android 应用程序,我试图将搜索栏的默认颜色从黄色更改为任何其他颜色。我创建了一个位于所有 3 个可绘制对象中的 xml 文件并运行了该项目,但搜索栏的颜色仍然没有改变。 下面是我和 irc 的一位同事一直在编写的代码。
<?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
}
If anybody knows what i'm doing wrong please let me know.
I created an android app and I am trying to change the default color of the seekbar from yellow to any other color. I created an xml file located in all 3 drawables and ran the project but the color of the seekbar still isnt changing color.
Below is the code me and a fellow mate from irc have been working on.
<?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>
This is my java code
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
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,基本上我需要做的就是进入我的 main.xml 文件,而不是位于drawables 文件夹中的文件,然后确保将
myprogress 放在位于drawables 文件夹中的.xml 文件的名称中。
Okay so basically all i needed to do is go into my main.xml file not the one located in the drawables folder and then make sure to put
where myprogress is the name of my .xml file located in the drawables folder.