如何样式动态设置的RatingBar,以便在Android中创建自定义搜索栏 [英] How to dynamically set the Style to RatingBar in order to create Custom SeekBar in Android

查看:214
本文介绍了如何样式动态设置的RatingBar,以便在Android中创建自定义搜索栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过layout.xml其工作正常。

Through layout.xml it is working.

<RatingBar 
  android:id="@+id/hotel_rating_bar"
  style="@style/custom_ratingbar" />

但我想动态设置样式。

But i want to set the style Dynamically.

任何回答将是非常美联社preciated ...

Any Answer will be highly appreciated...

推荐答案

通过动态改变的观点在运行时的风格还不支持在Android中,除了 TextViews <一个href=\"http://developer.android.com/reference/android/widget/TextView.html#setTextAppearance%28android.content.Context,%20int%29\"相对=nofollow> setTextAppearance 。

Dynamically changing the style of views at runtime is not yet supported in Android, except for TextViews via setTextAppearance.

您必须设置样式视图获取绘制前,结果
无论是通过XML或通过Java在构造函数中。

You have to set the style before the view gets drawn,
either via XML or via Java in the constructor.

RatingBar ratingBar = new RatingBar(context, null, android.R.attr.ratingBarStyleSmall);

这篇关于如何样式动态设置的RatingBar,以便在Android中创建自定义搜索栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆