代码拉取完成,页面将自动刷新
Developers can use RatingBar to implement show rating's, like feedback or other needed.
In xml
<com.hedgehog.ratingbar.RatingBar
ohos:id="$+id:ratingbar"
ohos:height="match_content"
ohos:width="match_parent"
ohos:alignment="center"
ohos:layout_alignment="horizontal_center"
app:clickable="true"
app:halfstart="true"
app:starImageHeight="90"
app:starImagePadding="20"
app:starImageWidth="70"
/>
</DirectionalLayout>
###method statement
method | action |
---|---|
app:clickable="true" | Could you click |
app:halfstart="true" | Whether to support half a star |
app:starCount="N" | The total number of stars (int) |
app:starImageHeight="90" | the height of the stars |
app:starImageWidth="70" | the width of the star |
app:starImagePadding="20" | the padding of the star |
#2. In Java code
RatingBar mRatingBar = (RatingBar) findComponentById(ResourceTable.Id_ratingbar);
mRatingBar.setStarEmptyDrawable(ResourceTable.Media_star_empty);
mRatingBar.setStarHalfDrawable(ResourceTable.Media_star_half);
mRatingBar.setStarFillDrawable(ResourceTable.Media_star_full);
mRatingBar.setStarCount(STAR_COUNT);
mRatingBar.halfStar(true);
mRatingBar.setmClickable(true);
mRatingBar.setStarImageWidth(IMAGE_WIDTH);
mRatingBar.setStarImageHeight(IMAGE_HEIGHT);
mRatingBar.setStar(DEFAULT_STAR_VALUE);
mRatingBar.setImagePadding(PADDING_100);
mRatingBar.setOnRatingChangeListener(RatingCount -> {
new ToastDialog(MainAbilitySlice.this).setText("the fill star is" + RatingCount).show();
});
###method statement
method | action |
---|---|
mRatingBar.setStarCount(5); | The total number of stars |
mRatingBar.setStar(2.5f); | Fill the total number of the stars |
mRatingBar.halfStar(true); | Whether set up half a star |
mRatingBar.setmClickable(true); | Whether the Settings can be click |
mRatingBar.setStarImageWidth(120f); | the width of the stars |
mRatingBar.setStarImageHeight(60f); | the height of the stars |
mRatingBar.setImagePadding(35); | the padding of the stars |
Using the ratingbar.har, make sure to add ratingbar.har file in the entry/libs folder.
Modify entry build.gradle as below :
dependencies {
implementation fileTree(dir: 'libs', include: [' *.jar', ' *.har'])
}
For using RatingBar module in sample app, Add the dependencies in entry/build.gradle as below :
Modify entry build.gradle as below :
dependencies {
implementation project(path: ':ratingbar')
}
For using RatingBar from a remote repository in separate application, add the below dependencies :
Modify entry build.gradle as below :
dependencies {
implementation 'io.openharmony.tpc.thirdlib:Ratingbar:1.0.1'
}
Copyright 2015 hedge_hog
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型