Я пытаюсь установить RatingBar
только с 5 звездами, но он расширяется, чтобы заполнить ширину экрана.Невозможно изменить ширину и количество звезд RatingBar
Я обнаружил аналогичные проблемы:
- How to make RatingBar to show five stars
- Android RatingBar - a complete mess
- android rating bar xml and numStars
Тем не менее, большую часть времени раствор должен установить ширину, чтобы wrap_content
но ширина меня всегда было wrap_content
.
Это мой макет. Если вы прокрутите до дна, вы увидите два RatingBar
сек:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableLayout
android:id="@+id/add_spot_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:shrinkColumns="1"
android:stretchColumns="1" >
<TableRow
android:layout_marginBottom="2sp"
android:layout_marginTop="2sp" >
<TextView android:text="Distance:" />
<TextView android:id="@+id/distancePopup" />
</TableRow>
<TableRow
android:layout_marginBottom="2sp"
android:layout_marginTop="2sp" >
<TextView android:text="Address:" />
<TextView android:id="@+id/addrPopup" />
</TableRow>
<TableRow
android:layout_marginBottom="2sp"
android:layout_marginTop="2sp" >
<TextView android:text="Type:" />
<TextView android:id="@+id/typePopup" />
</TableRow>
<TableRow
android:layout_marginBottom="2sp"
android:layout_marginTop="2sp" >
<TextView android:text="Terrain:" />
<RatingBar
android:id="@+id/terrainPopup"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:isIndicator="true"
android:max="5"
android:numStars="5"
android:stepSize="1" />
</TableRow>
<TableRow>
<TextView android:text="Difficulty:" />
<RatingBar
android:id="@+id/difficultyPopup"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:isIndicator="true"
android:max="5"
android:numStars="5"
android:stepSize="0.1" />
</TableRow>
<TableRow
android:layout_marginBottom="2sp"
android:layout_marginTop="2sp" >
<TextView android:text="Description:" />
<TextView
android:id="@+id/descPopup"
android:gravity="top"
android:lines="2"
android:maxLines="2"
android:scrollHorizontally="false" />
</TableRow>
</TableLayout>
</ScrollView>
Это то, что он выглядит следующим образом:
Это решило для меня - это, если он выше – user43043