简体   繁体   English

从右到左填充Ratingbar Star的xml布局

[英]Fill ratingbar star right to left xml layout

How to fill ratingbar's stars from right to left ? 如何从右到左填充Ratingbar的星星?

EDIT : I tried this : 编辑:我试过了:

android:align_right = "true"

but not works ... also tryin the deliverable 但不起作用...也尝试交付

<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

   <item android:id="@+android:id/background"
       android:drawable="@drawable/star_empty" />
   <item android:id="@+android:id/secondaryProgress"
       android:drawable="@drawable/star_empty" />
   <item android:id="@+android:id/progress"
       android:drawable="@drawable/star_fill" />
</layer-list>

swapping star_fill and star_empty also did nothing 交换star_fill和star_empty也无济于事

A very simple way is adding 一种非常简单的方法是添加

android:supportsRtl="true" android:supportsRtl =“ true”

to android manifest in application tag. 到清单文件中的android清单。 Remember that it will only work in API 17 and later. 请记住,它仅在API 17及更高版本中有效。

Another hacky way is to add 另一种方法是添加

android:rotation="180" android:rotation =“ 180”

android:scaleY="-1" // this will flip the view vertically android:scaleY =“-1” //这将垂直翻转视图

Finally if you do not like any of above solutions you can play tricks with displaying drawables and use reverse calculations. 最后,如果您不喜欢上述任何解决方案,则可以通过显示可绘制对象来玩弄花样并使用反向计算。

for example if the rating is 3/5 you can show it 2/5 with inverse image drawables. 例如,如果评分为3/5,则可以使用反面图像绘制将其显示为2/5。

try that 试试看

android:rotationY="180" android:rotationY =“ 180”

I think rotation="180" is a good trick. 我认为rotation =“ 180”是个好把戏。 Also, you can use scaleY="-1" to flip each view vertically (and scaleX="-1" for horizontal). 另外,您可以使用scaleY =“-1”垂直翻转每个视图(对于水平视图,可以使用scaleX =“-1”)。 This trick will fix the upside-down problem. 这个技巧将解决倒置问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM