
编辑:
问题1)已解决.但是我仍然无法更改Progressbar的颜色.我尝试使用自己的主题(请参见下面的代码).
我希望我的Progressbar看起来像下面的图像.我已经在ListVIEw上方创建了一个Progressbar.我在relativeLayout中使用ListVIEw,Progressbar和两个TextVIEw.
我的问题:
1.) How can I align the
TextVIEwsabove theProgressbarin the way shown below?
2.) How can I set the color of theProgressbaritself and the Background color of theProgressbar?
MainActivity.xml
<Progressbar androID:ID="@+ID/progressbar" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:layout_below="@+ID/progressbarText" androID:progress="0" androID:max="100" androID:paddingtop="0dp" androID:paddingBottom="10dp" androID:paddingleft="10dp" androID:paddingRight="10dp" androID:theme="@style/progressbartheme" />styles.xml
<resources><!-- Base application theme. --><style name="Apptheme" parent="theme.AppCompat.light.DarkActionbar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item></style><style name="Dialogtheme" parent="theme.AppCompat.light.Dialog"> <item name="colorAccent">@androID:color/holo_green_dark</item></style><style name="progressbartheme" parent="@style/theme.AppCompat"> <item name="colorAccent">@color/myRedcolor</item></style></resources>解决方法:
1.) How can I align the TextVIEws above the Progressbar in the way shown below?
尝试这个:
<?xml version="1.0" enCoding="utf-8"?><relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:gravity="center_horizontal"> <Progressbar androID:ID="@+ID/progressCircle" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_centerInParent="true" /> <TextVIEw androID:ID="@+ID/txtvstatusCircle" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_above="@ID/progressCircle" androID:layout_alignParentStart="true" androID:text="Daily Progress" androID:textSize="18sp" /> <TextVIEw androID:ID="@+ID/txtPercent" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_above="@ID/progressCircle" androID:layout_alignParentEnd="true" androID:text="0 %" androID:textSize="18sp" /></relativeLayout>2.) How can I set the color of the
Progressbaritself and the Background color of theProgressbar?
在您的styles.xml中:
<style name="progressbarBlue" parent="@style/theme.AppCompat"> <item name="colorAccent">@color/myBluecolor</item></style>然后在xml中设置为Progressbar主题:
<Progressbar ... androID:theme="@style/progressbarBlue" />关于Progressbar本身,无论您为样式中的Accentcolor选择什么,都将为Progressbar设置.因此更改颜色:
<item name="colorAccent">@color/colorAccent/item>会成功的.
输出:
总结以上是内存溢出为你收集整理的java-如何创建自定义ProgressBar全部内容,希望文章能够帮你解决java-如何创建自定义ProgressBar所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)