更新:当我将其更改为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“来显示最大星号 –