更新:當我將其更改爲ConstraintLayout而不是RelativeLayout時,我更容易調整星星並使其正確。但我仍然想知道在ReletiveLayout中是否有一種方法可以調整。任何想法?android studio:調整ratingBar明星位置
我正在使用android studio製作帶有ratingBar的APP。現在我的問題是,無論我如何調整ratingBar的位置,它都無法在虛擬機或實際設備上正確顯示。例如,當它是完整的,並在XML設計頁面在中間,在設備上最右邊的明星中最右邊的角落被切斷一點點,像下面的圖片顯示:
我的代碼調整ratingBar佈局是這樣的:
<RatingBar
android:id="@+id/ratingBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="7"
android:scaleX="0.7"
android:scaleY="0.7"
android:stepSize="1"
app:layout_constraintBottom_toBottomOf="@id/button3"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_below="@+id/imageView"
android:layout_centerHorizontal="true" />
我不知道問題出在哪裏,有人有想法嗎?
呵呵,另外一個信息是,這個ratingBar是設計在標籤活動的一個片段頁面上的,而這個頁面佈局是RelativeLayout,這有什麼關係嗎?
在此先感謝!
先給一個'靜width'你' RatingBar「,因爲這是一個問題,如果您將寬度設置爲wrap_content,則會削減RatingBar並使用android:max =」7「來顯示最大星號 –