你好,游客 登录 注册 搜索
背景:
阅读新闻

Android图片浏览器之实现显示图片的标题

[日期:2011-10-20] 来源:Linux社区  作者:badboy1110 [字体:大 中 小]
重写的Gallery:
  1. package cn.yj3g.view;  
  2.   
  3. import Android.content.Context;  
  4. import android.util.AttributeSet;  
  5. import android.view.MotionEvent;  
  6. import android.widget.Gallery;  
  7.   
  8. public class MyGallery extends Gallery  
  9. {  
  10.   
  11.     public MyGallery(Context context, AttributeSet attrs)  
  12.     {  
  13.         super(context, attrs);  
  14.     }  
  15.   
  16.     @Override  
  17.     public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)  
  18.     {  
  19.         //  velocityX/3,这个参数是把速度将为原来的1/3   
  20.         return super.onFling(e1, e2, velocityX / 3, velocityY);  
  21.     }  
  22. }  
Gallery的item:

gallery_item.xml

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:orientation="vertical" android:layout_width="match_parent"  
  4.     android:layout_height="match_parent">  
  5.     <ImageView android:id="@+id/item_gallery_image"   
  6.         android:layout_width="fill_parent"  
  7.         android:layout_height="fill_parent"  
  8.         android:layout_weight="1"  
  9.         android:scaleType="fitXY"/>  
  10.     <TextView android:id="@+id/item_gallery_text"  
  11.         android:layout_width="fill_parent"   
  12.         android:layout_height="wrap_content"  
  13.         android:gravity="center"/>  
  14.   
  15. </LinearLayout>  

image_switcher_1.xml(这个是从android的API  DEMO里面扒出来的  —  —!)

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <!-- Copyright (C) 2007 The Android Open Source Project  
  3.   
  4.      Licensed under the Apache License, Version 2.0 (the "License");  
  5.      you may not use this file except in compliance with the License.  
  6.      You may obtain a copy of the License at  
  7.     
  8.           http://www.apache.org/licenses/LICENSE-2.0  
  9.     
  10.      Unless required by applicable law or agreed to in writing, software  
  11.      distributed under the License is distributed on an "AS IS" BASIS,  
  12.      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
  13.      See the License for the specific language governing permissions and  
  14.      limitations under the License.  
  15. -->  
  16.   
  17. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"   
  18.     android:layout_width="match_parent"   
  19.     android:layout_height="match_parent"  
  20.     android:orientation="vertical">   
  21.     <cn.yj3g.view.MyGallery android:id="@+id/gallery"  
  22.         android:background="#55000000"  
  23.         android:layout_width="match_parent"  
  24.         android:layout_height="80dp"  
  25.         android:gravity="center_vertical"  
  26.          
  27.         android:spacing="8dp"  
  28.     />  
  29.     <ImageSwitcher android:id="@+id/switcher"  
  30.         android:layout_width="match_parent"  
  31.         android:layout_height="match_parent"  
  32.         android:layout_weight="1"  
  33.     />  
  34.       
  35. </LinearLayout>  
linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款