• 24天 @自定义RatingBar & 将Activity放入Dialog & 自定动画


    RatingBar是我们在系统显示分数的好组件,但是我们一般想把RatingBar装饰的更好看,想把更好看的图片用来替换系统默认的图片,系统默认的样子是这样的: 
     
    下图是个不错的选择哦: 
     
    想要实现如上效果,首先我们在styles.xml写入一个样式: 

    Xml代码  收藏代码
    1. <?xml version="1.0" encoding="utf-8"?>  
    2. <resources>  
    3.     <style name="foodRatingBar" parent="@android:style/Widget.RatingBar">  
    4.         <item name="android:progressDrawable">@drawable/food_ratingbar_full</item>  
    5.         <item name="android:minHeight">48dip</item>  
    6.         <item name="android:maxHeight">48dip</item>  
    7.     </style>  
    8. </resources>  


    然后在Drawable文件夹下建food_rating_bar_full.xml文件,内容如下: 

    Xml代码  收藏代码
    1. <?xml version="1.0" encoding="utf-8"?>  
    2. <layer-list xmlns:android="http://schemas.android.com/apk/res/android">  
    3.     <item android:id="@+android:id/background"  
    4.           android:drawable="@drawable/food_ratingbar_full_empty" />  
    5.     <item android:id="@+android:id/secondaryProgress"  
    6.           android:drawable="@drawable/food_ratingbar_full_empty" />  
    7.     <item android:id="@+android:id/progress"  
    8.           android:drawable="@drawable/food_ratingbar_full_filled" />  
    9. </layer-list>  


    food_ratingbar_full_empty是代表没有选中图片效果,food_ratingbar_full_filled选中图片效果。 
    最后将style放入RatingBar中,即可实现你的图片效果: 

    Xml代码  收藏代码
      1. <RatingBar   android:id="@+id/my_rating_bar"  
      2.             ...  
      3.             style="@style/foodRatingBar" />  

    ++++++++++++++++++++++++++++++++++++

    <activity
    android:name="com.chexiaodi.activity.DialogActivity"
    android:label="@string/title_activity_vertify"
    android:screenOrientation="portrait"
    android:theme="@android:style/Theme.Dialog" >
    </activity>

    只需要将设置Theme.Dialog就可以了

    ======================================

    1. <set xmlns:android="http://schemas.android.com/apk/res/android">  
    2.   <translate   
    3.       android:fromXDelta="0"   
    4.       android:toXDelta="100%"   
    5.       android:duration="300"/>  
    6.   
    7.   <alpha   
    8.     android:fromAlpha="0.0"   
    9.     android:toAlpha="1.0"   
    10.     android:duration="300" />  
    11. </set> 
  • 相关阅读:
    android获得屏幕高度和宽度
    Android中RelativeLayout各个属性的含义
    Android JNI知识简介
    Android结束进程方法
    android开发中的图片资源问题
    android framework下public.xml中添加资源问题
    I'm back
    test,exec,match,replace方法区别 正则
    fiddler抓包工具 https抓取 ios手机端抓取
    前端优化方案
  • 原文地址:https://www.cnblogs.com/linxiaojiang/p/2986027.html
Copyright © 2020-2023  润新知