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>  
  • 相关阅读:
    关于用mybatis调用存储过程时的入参和出参的传递方法
    Bootstrap系列 -- 35. 按钮的向下向上三角形
    Bootstrap系列 -- 34. 按钮下拉菜单
    Bootstrap系列 -- 33. 等分按钮
    Bootstrap系列 -- 32. 按钮垂直分组
    Bootstrap系列 -- 31.嵌套分组
    Bootstrap系列 -- 30. 按钮工具栏
    Bootstrap系列 -- 29. 按钮组
    Bootstrap系列 -- 28. 下拉菜单状态
    Bootstrap系列 -- 27. 下拉菜单对齐方式
  • 原文地址:https://www.cnblogs.com/hjtdlx/p/3942290.html
Copyright © 2011-2022 走看看