zoukankan      html  css  js  c++  java
  • 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> 
  • 相关阅读:
    HDU2586 How far away?(tarjan的LCA)
    You Raise Me Up
    POJ2891 Strange Way to Express Integers(中国剩余定理)
    POJ2142 The Balance(扩展欧几里得)
    HDU 1166模仿大牛写的线段树
    NetWord Dinic
    HDU 1754 线段树裸题
    hdu1394 Minimum Inversion Number
    hdu2795 Billboard
    【完全版】线段树
  • 原文地址:https://www.cnblogs.com/linxiaojiang/p/2986027.html
Copyright © 2011-2022 走看看