[英]Android ratingbar with tablelayout
我在具有4列的应用程序中使用TableLayout。 当我以layout_span=3
连续插入评级栏时,星星无法正常工作。
例如,我给出了numStars=5
,但它显示了6星的2/3 。 同样,如果我单击第三颗星,它会选择3.25颗星,如果选择第四颗,则会突出显示4.5颗,依此类推...缩放比例无法正常工作。
我尝试将layout_height更改为wrap_content,但结果相同。 仅当我删除layout_span时,它才能正常工作,但在这种情况下,我其他行的列会变形。
有人可以帮助我解决什么问题吗? 如果这是正常现象,那么如何使用layout_span获得正确的评分栏?
<TableRow
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<TextView
android:id="@+id/rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/rating" />
<RatingBar
android:id="@+id/add_rating"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_span="3"
android:numStars="5"
android:stepSize="1"
android:rating="4" />
</TableRow>
// NORMAL ROW
<TableRow
android:id="@+id/tr12"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<TextView
android:id="@+id/lab_datepurchased"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/datepurchased" />
<EditText
android:id="@+id/add_datepurchased"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/dateinput" />
<TextView
android:id="@+id/lab_shelfno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/shelfno" />
<EditText
android:id="@+id/add_shelfno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/definputtext2" />
</TableRow>
// try this
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/banner_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<TableRow
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center">
<TextView
android:id="@+id/rating"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="rating" />
<RatingBar
android:id="@+id/add_rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:stepSize="1"
android:rating="4" />
</TableRow>
<TableRow
android:id="@+id/tr12"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center">
<TextView
android:id="@+id/lab_datepurchased"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="@string/datepurchased" />
<EditText
android:id="@+id/add_datepurchased"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/dateinput" />
<TextView
android:id="@+id/lab_shelfno"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="@string/shelfno" />
<EditText
android:id="@+id/add_shelfno"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/definputtext2" />
</TableRow>
</TableLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.