J'essaie actuellement d'utiliser les pondérations LinearLayout
s afin de diviser la largeur de l'écran de manière égale. Dans l'une de ces moitiés, je voulais placer un RatingBar
directement dans le centre. La mise en page que j'ai est actuellement comme ci-dessous:RatingBar est coupé horizontalement lorsqu'il est affiché à l'intérieur d'un LinearLayout pondéré
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<RatingBar
android:id="@+id/rating_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:isIndicator="true"
android:max="5"
android:numStars="5"
android:scaleX="0.5"
android:scaleY="0.5"
tools:rating="3" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:background="@android:color/darker_gray" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/test" />
</LinearLayout>
</LinearLayout>
La question que je me rends compte est que le RatingBar
est coupé horizontalement hors et ne montrant que 3,5 étoiles. Si je déplace le RatingBar
sur un LinearLayout
pondéré alors il affiche comme je m'attendais. Je ne connais pas d'autre moyen de diviser également l'écran autrement qu'en utilisant la pondération. Une solution pour soit diviser l'écran de manière égale sans pondération ou un moyen d'afficher le RatingBar
correctement à l'intérieur serait grandement appréciée.