- package cn.yj3g.view;
- import Android.content.Context;
- import android.util.AttributeSet;
- import android.view.MotionEvent;
- import android.widget.Gallery;
- public class MyGallery extends Gallery
- {
- public MyGallery(Context context, AttributeSet attrs)
- {
- super(context, attrs);
- }
- @Override
- public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
- {
- // velocityX/3,这个参数是把速度将为原来的1/3
- return super.onFling(e1, e2, velocityX / 3, velocityY);
- }
- }
gallery_item.xml
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="match_parent"
- android:layout_height="match_parent">
- <ImageView android:id="@+id/item_gallery_image"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_weight="1"
- android:scaleType="fitXY"/>
- <TextView android:id="@+id/item_gallery_text"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:gravity="center"/>
- </LinearLayout>
image_switcher_1.xml(这个是从android的API DEMO里面扒出来的 — —!)
- <?xml version="1.0" encoding="utf-8"?>
- <!-- Copyright (C) 2007 The Android Open Source Project
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
- <cn.yj3g.view.MyGallery android:id="@+id/gallery"
- android:background="#55000000"
- android:layout_width="match_parent"
- android:layout_height="80dp"
- android:gravity="center_vertical"
- android:spacing="8dp"
- />
- <ImageSwitcher android:id="@+id/switcher"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1"
- />
- </LinearLayout>
