[英]Android ratingbar with tablelayout
I am using TableLayout in my application with 4 columns. 我在具有4列的应用程序中使用TableLayout。 When I insert a rating bar in a row, with
layout_span=3
, the stars are not working as expected. 当我以
layout_span=3
连续插入评级栏时,星星无法正常工作。
For Example, I gave numStars=5
, but it is showing 2/3 of 6th star. 例如,我给出了
numStars=5
,但它显示了6星的2/3 。 Also if I click on 3rd star, it selects 3.25 stars, if select 4th, 4.5 is highlighted and so on ... the scaling is not working properly. 同样,如果我单击第三颗星,它会选择3.25颗星,如果选择第四颗,则会突出显示4.5颗,依此类推...缩放比例无法正常工作。
I tried changing layout_height to wrap_content, but same result. 我尝试将layout_height更改为wrap_content,但结果相同。 Only if I delete layout_span, then it works fine, but in that case my columns of other rows have distortion.
仅当我删除layout_span时,它才能正常工作,但在这种情况下,我其他行的列会变形。
Can anyone please help me regarding what is the issue? 有人可以帮助我解决什么问题吗? And if this is the normal behavior, then how can I get proper rating bar with 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.