zoukankan      html  css  js  c++  java
  • android gallery 自定义边框+幻灯片

    最近在项目中用到图片轮播,试了Gallery,ViewFlipper,ViewPager,感觉Gallery最符合需求,但是Gallery的系统边框很难看,项目中要求用自己的背景图片。

    下面来看一下使用Gallery实现图片轮播

    运行效果:


    布局文件:

     

    [java] view plaincopy
     
    1. <FrameLayout  
    2.   
    3.   
    4.   
    5.   
    6.  >  
    7.   
    8.   
    9.   
    10.   
    11.  />  
    12.   
    13.   
    14.   
    15.   
    16.   
    17.   
    18.   
    19.  >  
    20.   
    21.   
    22.   
    23.  />  
    24.   
    25.   
    26.   
    27.   
    28.   
    29.  />  
    30.   
    31.   
    32.   
    33.   
    34.   
    35.   
    36.  />  
    37. </FrameLayout>  

    其中, android:fadingEdge="none"消除图片两边的阴影。使用FrameLayout在底部显示小圆点

     

     

    [java] view plaincopy
     
    1. publicclassextends private privateint;  
    2. private  
    3. privatestaticfinalint;  
    4.   
    5. publicvoid super ].setImageDrawable(getBaseContext().getResources()  
    6. newthis new );  
    7. privatevoid new privatenew   
    8. publicvoid new ;  
    9.      * 开一个线程执行耗时操作 
    10.      */ privatenew   
    11. publicvoid super switch case:  
    12. break default break      * 设置小圆点显示,position会一直增加,如果要循环显示图片,需要对position取余,否则数组越界 
    13.      */ privatenew   
    14. publicvoid intlong int if) {  
    15. ].setImageDrawable(getBaseContext()  
    16. if)) {  
    17. ].setImageDrawable(getBaseContext()  
    18. if) {  
    19. ]  
    20.   
    21. publicvoid   
    22.      * 点击事件,点击图片进入SecondActivity 
    23.      */ privatenew   
    24. publicvoidint long new thisclass }  

    ImageAdapter类,重写android.widget.BaseAdapter,用于描述图像信息。

    [java] view plaincopy
     
    1. publicclassextends private privateint privatestaticfinalint;  
    2. public this   
    3. publicint return  
    4.   
    5. publicint return   
    6. publiclongint return   
    7. publicint new new new );  
    8.   
    9. return }  


    如果用系统背景,可以这样写

     

     

    [java] view plaincopy
     
    1. int private public // 获得Gallery组件的属性 );   
    2. }  

    在getview中设置

     

     

    [java] view plaincopy
     
    1. imageView.setBackgroundResource(mGalleryItemBackground);  

    Gallery组件属性信息定义在resvaluesattrs.xml

     

     

    [java] view plaincopy
     
    1. <?xml version= encoding=?>  
    2. >  
    3.  />  
    4. </resources>  
  • 相关阅读:
    P1144 最短路计数 题解 最短路应用题
    C++高精度加减乘除模板
    HDU3746 Teacher YYF 题解 KMP算法
    POJ3080 Blue Jeans 题解 KMP算法
    POJ2185 Milking Grid 题解 KMP算法
    POJ2752 Seek the Name, Seek the Fame 题解 KMP算法
    POJ2406 Power Strings 题解 KMP算法
    HDU2087 剪花布条 题解 KMP算法
    eclipse创建maven项目(详细)
    maven的作用及优势
  • 原文地址:https://www.cnblogs.com/hjtdlx/p/3942290.html
Copyright © 2011-2022 走看看