淘宝(阿里百川)手机客户端开发日记第二篇 android首页之顶部轮播特效制作 (二)

1.我们来设计flash_slide.xml 布局,这个xml主要做成模块化,方便其它的activity可以动态去调用。

flash_slide.xml内容如下:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"
android:layout_height="match_parent"
>
<android.support.v4.view.ViewPager
android:id="@+id/flash_content"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<LinearLayout

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_alignParentBottom="true"

android:gravity="center"

android:background="#000000"

>

<ImageView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:src="@drawable/dot_focus"

/>

<ImageView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:src="@drawable/dot_blur"

android:layout_marginLeft="6dp"

/>

  </LinearLayout>

</RelativeLayout>

效果如图:

现在,我们开始建立对应的代码,新建一个com.yushengbo.widget包,在此包下,建立一个继承自FrameLayout的自定义的View类。

 1 public class FlashSlide extends FrameLayout {
 2
 3     private List<ImageView> circleDotList; //原點
 4
 5     private List<ImageView> imagesList; //圖片
 6
 7
 8
 9     private int[] resouceIds = { R.drawable.flash1,R.drawable.flash2,R.drawable.flash3,R.drawable.flash4,R.drawable.flash5 };
10
11     private int curItemIndex=0; //當前選中的圖片
12
13     private ViewPager viewPager;
14
15     public FlashSlide(Context context, AttributeSet attrs, int defStyleAttr) {
16
17     super(context, attrs, defStyleAttr);
18
19     InitData(context);
20
21 }
22
23 void InitData(Context context)
24
25 {
26
27   for(int i=0;i<resouceIds.length;i++)
28
29   {
30
31     ImageView iv = new ImageView(context);
32
33     iv.setImageResource(resouceIds[i]);
34
35     ImageView ic= new ImageView(context);
36
37     ic.setImageResource(R.drawable.dot_blur);
38
39   }
40
41 }
42
43 void InitUi(Context context)
44
45 {
46
47   LayoutInflater.from(context).inflate(R.layout.flash_slide, this);
48
49   viewPager = (ViewPager)findViewById(R.id.flash_content);
50
51 }
52
53 }
时间: 2024-08-23 22:50:28

淘宝(阿里百川)手机客户端开发日记第二篇 android首页之顶部轮播特效制作 (二)的相关文章

淘宝(阿里百川)手机客户端开发日记第十篇 阿里百川服务器环境介绍

阿里百川的官方网址:http://baichuan.taobao.com/ ,具体详情,自己点击去查看. 提前声明:本人和淘宝一点关系没有,最近是自己有个项目,需要使用它们的平台,来开发android,IOS的客户端产品,所以将平时在实践过程中,很多重要的心得记下,方便自己后期遇到问题,随时查阅:同时,也能帮助很多爱好编程者提供一些资料,毫无其它目的,谢谢! 这节课,将向你介绍下它的大致内容:刚开始接触阿里百川,很多人会遇到各种各样的,貌似千奇百怪的问题,我将以简明的方式,让大家快速搭配环境,来

淘宝(阿里百川)手机客户端开发日记第十二篇 mysql的认识

我这里用的是wamp,大家可以到网上去下载对应的包,自行安装,对于程序员来讲,安装软件大部分都应该不是问题的,所以我不去将具体安装的方法. wamp安装好后,在我们屏幕的右下角, 这样的图标,我们右键点击它,由于我点击右键的时候,没法截图,只好用语言来描述了,我们要将其切换到在线状态.如果80端口被占用,你可能本地安装了IIS服务器,你需要去关闭它,IIS默认使用了80端口:或者你不关闭,你可以将wamp服务器端口改掉,比如8080端口.具体的方法,网上很多了,大家参照下把端口改掉,然后切换在线

淘宝(阿里百川)手机客户端开发日记第十篇 什么是淘宝客(七)

在淘宝客中,有淘宝联盟.卖家.淘客以及买家四个角色.他们每个都是不可缺失的一环,如图所示. (1)淘宝联盟(http://www.alimama.com/):一个推广平台,帮助卖家推广产品:帮助淘客赚取利润,每笔推广的交易抽取相应的服务费用. (2)卖家:佣金支出者,他们提供自己需要推广的商品到淘宝联盟,并设置每卖出一个产品愿意支付的佣金. (3)淘宝客:佣金赚取者,他们在淘宝联盟中找到卖家发布的产品,并且推广出去,当有买家通过自己的推广链接成交后,那么就能够赚到卖家所提供的佣金(其中一部分需要

淘宝(阿里百川)手机客户端开发日记第十五篇 JSON解析(二)

上一节,我们已经讲解了两个重要的类,JSONObject,JSONArray.这一节,我们将给出几个DEMO,来熟悉这两个类的用法! 首先,我给出一个JSON字符串: { "tae_items_list_response": { "items": { "x_item": [ { "istk":true, "mall":false, "nick":"zxh206", &

淘宝(阿里百川)手机客户端开发日记第十一篇 JSP+Servlet篇(一)

由于本人从事.net开发已有多年经验,今天由于工作需要,我只能学习下JSP+Servlet,至于java web提供了更好的开发框架MVC,现在由于时间关系,我只好用JSP+Servlet来搭建服务器端开发.主要是提供了客户端的广告位设置,引导页的设置,以及商品分类的设置,和商品的详情,最后是购物车(客户端). 首先,我们先认识下Java Web开发项目基本的结构 我们写Servlet,和我们.net开发里的服务器端开发类似.服务端的开发主要是和数据库,业务逻辑代码有很大关系.然后将数据投递给前

淘宝(阿里百川)手机客户端开发日记第六篇 广播机制详解(一)

public abstract class BroadcastReceiver; Base class for code that will receive intents sent by sendBroadcast(). If you don't need to send broadcasts across applications, consider using this class with LocalBroadcastManager instead of the more general

淘宝(阿里百川)手机客户端开发日记第六篇 Service详解(六)

Service和Thread的关系 不少初学者都可能会有这样的疑惑,Service和Thread到底有什么关系呢?什么时候应该用Service,什么时候又应该用Thread? 答案是Service和Thread之间没有任何关系! Service 是在后台运行的,但是它运行在主线程中,Service无法直接和UI进行交互,我们只有通过接口回调和广播机制(下一节将介绍广播机制)来实现对UI的操作: Thread 是用于开启一个子线程,执行一些耗时操作不会阻塞主线程的运行: 举个例子: 某些应用程序可

淘宝(阿里百川)手机客户端开发日记第六篇 Service详解(五)

我们现在对上一节中的DEMO进行改进,在服务中开启线程来执行. package com.example.service; import android.app.Service; import android.content.Intent; import android.os.Binder; import android.os.IBinder; import android.util.Log; import android.widget.Button; public class MyService

淘宝(阿里百川)手机客户端开发日记第六篇 Service详解(一)

public abstract class Service; [API文档关于Service类的介绍] A Service is an application component representing either an application's desire to perform a longer-running operation while not interacting with the user or to supply functionality for other appli