android ratingbar 高度,android - 如何减小Ratingbar的大小?
android - 如何减小Ratingbar的大小?
在我的活动中,我有一些评级栏。 但这个酒吧的大小是如此之大!我怎样才能让它变小?
编辑
感谢Gabriel Negut,我用以下样式做到了:
style = "?android:attr/ratingBarStyleSmall"
android:numStars = "5"
android:rating = "4" />
现在,尺寸减小但星数和等级不生效!为什么? 我有7颗星,其中6颗被选中。
Hesam asked 2019-07-14T07:28:15Z
13个解决方案
120 votes
我发布的原始链接现在已经破了(有一个很好的理由,为什么发布链接不是最好的方法)。 您必须使用ratingBarStyleSmall或继承自Widget.Material.RatingBar.Small的自定义样式(假设您在应用程序中使用Material Design)设置样式RatingBar。
选项1:
android:id="@+id/ratingBar"
style="?android:attr/ratingBarStyleSmall"
... />
选项2:
// styles.xml
... // Additional customizations
// layout.xml
android:id="@+id/ratingBar"
style="@style/customRatingBar"
... />
Gabriel Negut answered 2019-07-14T07:28:41Z
60 votes
如果要以小尺寸显示评级栏,则只需将此代码复制并粘贴到项目中即可。
android:id="@+id/MyRating"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/getRating"
android:isIndicator="true"
android:numStars="5"
android:stepSize="0.1" />
Pir Fahim Shah answered 2019-07-14T07:29:11Z
58 votes
这是我的解决方案,经过大量努力降低小尺寸的评级栏,甚至没有丑陋的填充
android:id="@+id/listitemrating"
style="@android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleX=".5"
android:scaleY=".5"
android:transformPivotX="0dp"
android:transformPivotY="0dp"
android:isIndicator="true"
android:max="5" />
Sridhar Kulkarni answered 2019-07-14T07:29:38Z
37 votes
您可以在RatingBar的XML代码中设置它,使用scaleX和scaleY进行相应调整。 “1.0”将是正常大小,“。0”中的任何内容都会减少它,大于“1.0”的任何内容都会增加它。
android:id="@+id/ratingBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleX="0.5"
android:scaleY="0.5" />
ZeWolfe15 answered 2019-07-14T07:30:14Z
29 votes
下面的片段为我调整了ratingBar的大小
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ratingBar"
style="?android:attr/ratingBarStyleIndicator"
android:scaleX=".5"
android:rating="3.5"
android:scaleY=".5"
android:transformPivotX="0dp"
android:transformPivotY="0dp"
android:max="5"/>
Naveed Ahmad answered 2019-07-14T07:30:40Z
8 votes
工作实例
style="@style/RatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:rating="3.5"
android:stepSize="0.5" />
并将其添加到样式xml文件中
@color/primary_light
@color/primary_dark
这样您就不需要自定义ratingBar。
Hammad Tariq answered 2019-07-14T07:31:21Z
6 votes
style="?android:attr/ratingBarStyleIndicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
nafees4343 answered 2019-07-14T07:31:41Z
5 votes
在这里查看我的答案。 实现它的最佳方式。
15dp
15dp
@color/white
@color/home_add
并使用像
style="?android:attr/ratingBarStyleIndicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:isIndicator="false"
android:max="5"
android:rating="3"
android:scaleX=".8"
android:scaleY=".8"
android:theme="@style/MyRatingBar" />
AMAN SINGH answered 2019-07-14T07:32:15Z
3 votes
如果您在Linearlayout中使用带有weightSum的评级栏。 请确保您不应为评级栏指定layout_weight。 相反,该位置评级栏内部相对布局并赋予相对布局权重。 制作评级栏宽度包装内容。
android:layout_width="0dp"
android:layout_weight="30"
android:layout_gravity="center"
android:layout_height="wrap_content">
android:id="@+id/userRating"
style="@style/Widget.AppCompat.RatingBar.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:stepSize="1" />
Varnith Kumar M answered 2019-07-14T07:32:43Z
2 votes
如果您只需要默认样式,请确保您具有以下宽度/高度,否则numStars可能会混乱:
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Sean answered 2019-07-14T07:33:11Z
2 votes
使用Widget.AppCompat.RatingBar,您可以使用2种样式; Indicator和Small分别适用于大小尺寸。 见下面的例子。
android:id="@+id/rating_star_value"
style="@style/Widget.AppCompat.RatingBar.Small"
... />
Ugokoli answered 2019-07-14T07:33:41Z
2 votes
在RatingBar给出属性:
style="?android:attr/ratingBarStyleIndicator"
rajlaxmi_jagdale answered 2019-07-14T07:34:09Z
0 votes
对于那些以编程方式创建评级栏并希望设置小评级栏而不是默认大评级栏的人
RatingBar ratingBar = new RatingBar(getContext(),null,android.R.attr.ratingBarStyleSmall); ratingBar.setEnabled(假); ratingBar.setStepSize(Float.parseFloat(“0.5”)); //用于启用半星 ratingBar.setNumStars(5); ratingBar.setRating(值); linearLayoutRating.addView(的RatingBar); return linearLayoutRating; }
Sachin Tanpure answered 2019-07-14T07:34:45Z
android ratingbar 高度,android - 如何减小Ratingbar的大小?相关推荐
- android ratingbar 高度,Android RatingBar终极解决方案,大小、颜色、间距、样式随便定义...
用过RatingBar的都知道,这玩意比较坑,不好调整大小.间距.颜色及样式等难以自定义.这里给出一个RatingBar的终极解决方案-AndRatingBar. AndRatingBar开源库,它继 ...
- android ratingbar 高度,android (RatingBar)
1.星级评分条与拖动类似,运行用户拖动改变进度,通过星星显示进度,表达对每一事物的支持度. android:numStarts="5" 指定星级评分条有多少颗星 android:r ...
- android framelayout 高度,Android SupportLib – FrameLayout在CoordinatorLayout中与AppBarLayout消耗整个屏幕高度...
我目前在Android设计支持库的CoordinatorLayout中遇到了一个FrameLayout的问题,而在创建选项卡时,我遵循了这个 post的指示. 基本上大多数事情按预期工作,容器片段被充 ...
- android framelayout 高度,android - Android:如何将FrameLayout中的线性布局与底部对齐? - 堆栈内存溢出...
使用属性layout_gravity对齐FrameLayout中的任何视图 android:layout_gravity:"bottom" /> 但是,如果您尝试将其放置在其 ...
- android banner 高度,Android Banner 的简单使用步骤
Step 1: 依赖 //Banner implementation 'com.youth.banner:banner:1.4.10' implementation 'com.github.bumpt ...
- Android修改高度,android – 如何在运行时更改软键盘的高度?
原始解决方案发布在 https://stackoverflow.com/a/9695482/1241783但它没有解释所以在这里我延伸了一点. 1)创建一个扩展Keyboard类的新类,该类覆盖get ...
- android ratingbar 高度,简单实用的自定义AndroidRatingBar
作为一个初级小菜逼码农,刚做的几个项目都有设计到评分这一块的功能(感觉很少有应用不做吧--),系统自带的ratingbar用来用去真是费劲,背景图片还得去单独建立一个资源文件,用起来很是不简洁,就琢磨 ...
- android中的评分条(ratingBar)
Android 中文 API (40) -- RatingBar 前言 本章内容是 android.widget.RatingBar,译为"评分条",版本为Android 2.2 ...
- android 星级评论,Android自定义RatingBar(星级评分控件)
1.首先在Drawable下建立five_rating_bar.xml android:id="@android:id/background" android:drawable=& ...
最新文章
- UVa11300 Spreading the Wealth(数学问题)
- string 类的实现
- Groovy与Java集成常见的坑
- Java并发——结合CountDownLatch源码、Semaphore源码及ReentrantLock源码来看AQS原理
- mysql数据库group_key_【MySQL】数据库复制:组复制(Group Replication)
- xp系统怎样添加桌面计算机名,教你win10系统电脑桌面怎么添加日历
- 2023.TortoiseGit 工具
- 华为9月将带来鸿蒙系统2.0;张勇任阿里巴巴董事长后发布首封致股东信;iOS 14首个公测版发布​| 极客头条
- cookie怎样存储数据?
- 中切片工具怎么使用_技巧|Excel中切片器的2个使用方法!
- Flash CS 6绘图技巧之锁定填充
- yxy小蒟蒻的201113总结
- 论文笔记——Comparing to Learn
- 问题 B: Bumped!
- c++ packaged_task
- 只有一重循环的排序——侏儒排序(Gnome Sort)
- RecyclerView实现条目拖拽,左滑、右滑移除效果
- 【IDEA保姆级教程】快捷键
- VMware教程:设置 CentOS 7 共享文件夹
- ACM算法训练赛——STL(完结)