android - 评级明星从最后开始削减
问题描述
我已经实现了 android 原生评级栏,但是当我将星数设置为 10 时,它会从屏幕末端切断它在某些设备上发生的情况,谁能帮助我如何设法在所有移动设备上始终显示 10 星?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_marginBottom="@dimen/_15sdp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tValueLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/_5sdp"
android:textSize="@dimen/_11ssp" />
<RatingBar
android:id="@+id/ratingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/ratingBarStyleIndicator"
android:isIndicator="false"
android:layout_marginTop="@dimen/_5sdp"
android:stepSize="1.0" />
</LinearLayout>
解决方案
由于屏幕上没有空间容纳 10 颗星,您的 RatingBar 正在从头开始切割。解决方法是减小星的大小。没有直接的方法可以减小星的大小。在您的情况下, scaleX 和 scaleY 将起作用。请为 RatingBar 使用以下代码
<RatingBar
android:id="@+id/ratingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/ratingBarStyleIndicator"
android:isIndicator="false"
android:scaleX=".8"
android:scaleY=".8"
android:translationX="-10dp"
android:layout_marginTop="5dp"
android:stepSize="1.0" />
推荐阅读
- php - 如何使用 make 从 tgz 文件构建 php 扩展?
- android - 已弃用功能的问题
- xamarin.forms - mvvmcross xamarin.forms PictureChooser
- gradle - Gradle 预编译脚本插件:未找到外部 Quarkus 插件依赖项
- jasmine - 带有样式组件的酶安装
- c - C 加速递归
- r - R GGplot - County choropleth map - 如何在没有数据的情况下勾勒出州/县?
- json - 递归父子 JSON Postgresql
- gitlab - Gitlab:书签回购功能 - 如何以及什么?
- c# - ASP .NET 在表单请求后错误地将十进制数转换为数百