【问题标题】:Rating star is cutting from the end评级明星从最后开始削减
【发布时间】:2020-02-14 12:03:39
【问题描述】:

我已经实现了 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>

【问题讨论】:

  • 欢迎来到 SO 社区。请提供您的布局的完整代码。谢谢
  • @Muhammad Farhan 请检查我是否已更新问题
  • 为什么要在父布局中添加 layout_marginBottom ??
  • 请检查更新的答案@Android

标签: android android-layout screen-resolution ratingbar


【解决方案1】:

试试这个以最小化星星的大小

android:scaleX=".4"
android:scaleY=".4" 

希望对你有用

【讨论】:

  • 仍然从头开始切割
【解决方案2】:

由于屏幕中没有空间容纳 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" />

【讨论】:

  • 仍然从头开始切割
  • 然后请尝试使用 .6 或 .4 比例。
  • 它与 5 星合作,但当我设置 10 星时,它的切割
【解决方案3】:

根据需要更改宽度参数:

android:layout_width="xx dp"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-04
    • 2012-04-26
    相关资源
    最近更新 更多