RatingBar流泪、有脚、显示不全问题
来源:互联网 发布:java表格代码怎么写 编辑:程序博客网 时间:2024/04/30 08:58
项目中给ratingbar设置了style后星星”流泪“、”有脚“
ratingstars
<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@android:id/background" android:drawable="@mipmap/star_empty" /> <item android:id="@android:id/secondaryProgress" android:drawable="@mipmap/star_empty" /> <item android:id="@android:id/progress" android:drawable="@mipmap/star" /></layer-list>
style
<style name="RatingBar" parent="@android:style/Widget.RatingBar"> <item name="android:progressDrawable">@drawable/ratingstars</item> <item name="android:minHeight">22dp</item> <item name="android:maxHeight">22dp</item> </style>
xml
<RatingBar android:id="@+id/ratingbar" android:layout_width="wrap_content" android:layout_height="22dp" android:numStars="5" android:stepSize="1" style="@style/RatingBar" />
如果是在Adapter中就写在adapter里面,如果在Activity中就写在Activity中
try { Bitmap bmp = BitmapFactory.decodeResource(context.getResources(), R.mipmap.star); int scroeHeight = bmp.getHeight(); } catch (Exception e) { e.printStackTrace(); }// 在需要的地方设置LayoutParams 记得图片只需要初始化一次就可以了 if(scroeHeight!=0){ LinearLayout.LayoutParams llp = (LinearLayout.LayoutParams) ratingBar.getLayoutParams(); llp.width = -2;// 包裹内容 llp.height = scroeHeight; ratingBar.setLayoutParams(llp); }
LinearLayout.LayoutParams llp = (LinearLayout.LayoutParams) ratingBar.getLayoutParams();
这句是ratingbar的父布局是什么就用什么布局然后现在星星不流泪了,显示完全,但是最后一个星星最右边的角感觉少了一点 点,不过影响不大
0 0
- RatingBar流泪、有脚、显示不全问题
- RatingBar在真机上显示不全的问题
- Android 自定义RatingBar控件,显示不全问题
- RatingBar显示不全
- 自定RatingBar显示不全
- Android开发:自定义的RatingBar图标显示不全的解决方案
- RatingBar星星显示不全或星星图片被拉伸解决方案
- listview显示不全问题
- 布局显示不全问题
- EXT3日历显示不全问题
- 高分辨率AVD显示不全问题
- listview底部显示不全问题
- msChart坐标显示不全问题
- jsp页面显示不全问题
- GridPanel显示不全的问题
- IOS 模拟器显示不全问题
- ScrollView显示不全的问题
- WKWebView 内容显示不全问题
- 文章标题
- iOS 打包时出现在other items
- 梦想起航
- Linux系统下的常用命令
- robot framework读取Excel文件,并保存为list
- RatingBar流泪、有脚、显示不全问题
- (C++基础)浅谈继承与派生
- MYSQL(5)触发器
- [IO系统]16 IO调度器-NOOP
- Java读取文件byte转化String问题
- 【项目实战】从抽奖算法感受算法奥妙
- codeforces contest 785 a题
- 指针极简教程
- OA的项目