zoukankan      html  css  js  c++  java
  • android技巧总结

    技巧1. 在写布局文件时,有时不需要给控件指定text值,但是又想知道他的位置是否是自己想要他在的位置。这种情况只有在运行时给他指定text值才能确切地知道它显示的位置。

    现在有一种方法可以实现,即利用tools命名空间,在布局文件中给控件指定text值,让我们可以在预览时知道控件的位置,但在真实运行时不显示。

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >
    
        <TextView
            android:id="@+id/main_tv_ordercount"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingBottom="100dp"
            tools:text=" test"/>    //将tools代替android就可以实现该内容只在预览时显示的效果
    </RelativeLayout>

     技巧2.  加载数据时的进度条动画

         之前每次遇到需要用进度条的时候,如果不是产品需要,总是采用android自带的小黑圈来应付,不过看起来还真丑,也有去尝试写个漂亮点的自定义,总是不太满意。

    一次偶然的机会看到了github上的这个AVLoadingIndicatorView,简直太漂亮了,并且支持动画达20多种,还可以根据源码开发出自己想要的动画,用法简单,感谢开源,传送门:https://github.com/81813780/AVLoadingIndicatorView

         动画效果

    每种动画对应的名字如下:

    1. BallPulse
    2. BallGridPulse
    3. BallClipRotate
    4. SquareSpin
    5. BallClipRotatePulse
    6. BallClipRotateMultiple
    7. BallPulseRise
    8. BallRotate
    9. CubeTransition
    10. BallZigZag
    11. BallZigZagDeflect
    12. BallTrianglePath
    13. BallScale
    14. LineScale
    15. LineScaleParty
    16. BallScaleMultiple
    17. BallPulseSync
    18. BallBeat
    19. LineScalePulseOut
    20. LineScalePulseOutRapid
    21. BallScaleRipple
    22. BallScaleRippleMultiple
    23. BallSpinFadeLoader
    24. LineSpinFadeLoader
    25. TriangleSkewSpin
    26. Pacman
    27. BallGridBeat
    28. SemiCircleSpin
    29. BallRotateChase
    30. Orbit
    31. AudioEqualizer

    使用方法

    step 1.AndroidStudio框架引入配置:build.grade配置

    dependencies {
           compile 'com.wang.avi:library:1.0.5'
           compile 'com.nineoldandroids:library:2.4.0'
        }

    step 2. 布局文件

    <com.wang.avi.AVLoadingIndicatorView
            android:id="@+id/avloadingIndicatorView"
            android:layout_width="wrap_content"  //or your custom size
            android:layout_height="wrap_content"  //or your custom size
            android:visibility="visible"  //visible or gone
            app:indicator="BallPulse"    //指明采用哪种动画,动画名字与效果图一一对应
            app:indicator_color="your color"   //颜色指定
            />

    step 3. activity中调用

    void startAnim(){
            findViewById(R.id.avloadingIndicatorView).setVisibility(View.VISIBLE);
       }
    
       void stopAnim(){
            findViewById(R.id.avloadingIndicatorView).setVisibility(View.GONE);
       }

    上面的几步在github上都有说明,在此只作备忘,其它用法可参考作者上传的demo。

  • 相关阅读:
    WEBAPP开发技巧(手机网站开发注意事项)
    2014阿里前端线上笔试题
    [NOIp2008] 双栈排序 (二分图染色 + 贪心)
    [NOIp2012] 国王游戏(排序 + 贪心 + 高精度)
    关于错排公式以及扩展的一些小结论
    [NOI2009]诗人小G(dp + 决策单调性优化)
    Codeforces Round #429 (Div. 1) C. On the Bench(dp + 组合数)
    Educational Codeforces Round 33 (Rated for Div. 2) F. Subtree Minimum Query(主席树合并)
    Codeforces Round #511 (Div. 1) C. Region Separation(dp + 数论)
    Codeforces Round #471 (Div. 2) F. Heaps(dp)
  • 原文地址:https://www.cnblogs.com/lovemo1314/p/5580785.html
Copyright © 2011-2022 走看看