gpt4 book ai didi

android - 将数字与 RatingBar 对齐 - Android

转载 作者:行者123 更新时间:2023-11-29 18:40:36 25 4
gpt4 key购买 nike

我在我的应用程序中使用了 RatingBar 并为用户分配了 Stars 编号以方便用户,但只要设备发生变化,这些编号的对齐方式就会发生变化。虽然我为不同的屏幕使用了不同的布局,但在某些移动设备上它的格式仍然不正确。

What i want

enter image description here

what's showing on some mobiles

enter image description here

最佳答案

使用约束布局作为父级并适合线性布局。那应该可以正常工作。

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<RatingBar
android:id="@+id/ratingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_editor_absoluteX="38dp"
tools:layout_editor_absoluteY="192dp" />

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="@+id/ratingBar"
app:layout_constraintEnd_toEndOf="@+id/ratingBar"
app:layout_constraintStart_toStartOf="@+id/ratingBar">

<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:text="1"
android:textAlignment="center" />

<TextView
android:id="@+id/textView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:text="2"
android:textAlignment="center" />

<TextView
android:id="@+id/textView17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:text="3"
android:textAlignment="center" />

<TextView
android:id="@+id/textView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:text="4"
android:textAlignment="center" />

<TextView
android:id="@+id/textView19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:text="5"
android:textAlignment="center" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>

enter image description here

关于android - 将数字与 RatingBar 对齐 - Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53140142/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com