我确实读过如何从这里制作自定义评级条。但是我想让评级栏从服务器上检索图像。
有可能吗?怎么做到的?
发布于 2017-01-03 08:11:36
这可能不是确切的,但绝对是为了你的目的加上一些代码。

下面是示例代码
RatingBar mRatingBar = (RatingBar) findViewById(R.id.ratingbar);
mRatingBar.setStarEmptyDrawable(getResources().getDrawable(R.mipmap.star_empty));
mRatingBar.setStarHalfDrawable(getResources().getDrawable(R.mipmap.star_half));
mRatingBar.setStarFillDrawable(getResources().getDrawable(R.mipmap.star_full));
mRatingBar.setStarCount(5);
mRatingBar.setStar(2.5f);
mRatingBar.halfStar(true);
mRatingBar.setmClickable(true);
mRatingBar.setStarImageWidth(120f);
mRatingBar.setStarImageHeight(60f);
mRatingBar.setImagePadding(35);
mRatingBar.setOnRatingChangeListener(
new RatingBar.OnRatingChangeListener() {
@Override
public void onRatingChange(float RatingCount) {
Toast.makeText(MainActivity.this, "the fill star is" + RatingCount, Toast.LENGTH_SHORT).show();
}
}
);您可以在setStars中使用来自服务器的自己的映像。您所需要做的就是将您的映像从服务器转换为可绘制的
这是天平
compile 'com.hedgehog.ratingbar:app:1.1.2'有关详细说明和更新版本,请使用此github-链接
请试一试,让我知道你的意见。
发布于 2017-01-03 05:03:45
正如您所提到的答案这里,如果这是您的方式,那么这是不可能的,因为您不能在运行时将一个文件放在可绘制文件夹中,因为R.java文件是在编译时生成的。
https://stackoverflow.com/questions/41436535
复制相似问题