向导界面的开发

向导界面的开发。在向导界面中通过左右滑动显示应用的有关介绍,本例子中有5屏。这5屏分别在单独的xml文件中定义,然后通过LayoutInflater得到对应的view对象,将这5个View对象添加到控件ViewPager中。和ViewPager在同一界面的还有5个点,哪个View被显示时,其对应的点变成白色,没有显示出来的点变成灰色。

1. Activity对应的布局文件。布局文件中,ViewPager和点所在的布局所占空间分别占0.8和0.2,在layout_weight中体现出来。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="#000000"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    
    <android.support.v4.view.ViewPager
        android:id="@+id/viewPager"
        android:layout_marginTop="20dip"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="4" />
    
    <RelativeLayout
        android:id="@+id/llbottom"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:background="#000000" >
        <com.***.widget.PointWidget 
            android:id="@+id/llPoint"
	        android:layout_width="wrap_content"
	        android:layout_height="wrap_content"
	        android:layout_centerInParent="true"
	        android:background="#000000"
            />           
    </RelativeLayout>
</LinearLayout>

2. 在Activity的onCreate()方法中初始化ViewPager和PointWidget。PointWidget扩展自LinearLayout,其方法setPointCount(int)设置点的数量,本例是5个。

inflater = getLayoutInflater();  
pageViews = new ArrayList<View>();
view1 = (LinearLayout) inflater.inflate(R.layout.item01, null);
view2 = (LinearLayout) inflater.inflate(R.layout.item02, null);
view3 = (LinearLayout) inflater.inflate(R.layout.item03, null);
view4 = (LinearLayout) inflater.inflate(R.layout.item04, null);
view5 = (RelativeLayout) inflater.inflate(R.layout.item05, null);
pageViews.add(view1);  
pageViews.add(view2);  
pageViews.add(view3);  
pageViews.add(view4);  
pageViews.add(view5);  
pointWidget = (PointWidget)this.findViewById(R.id.llPoint);
pointWidget.setPointCount(pageViews.size());
viewPager = (ViewPager)this.findViewById(R.id.viewPager);

3. ViewPager中5个View其中第1~4个View内容最简单,只显示一张图片。xml文件中定义为线性布局里放了一个ImageView控件。

<ImageView 
	android:layout_width="fill_parent"
    	android:layout_height="fill_parent"
    	android:id="@+id/imageview1"
    	android:background="@drawable/guide1_1"
    	android:scaleType="fitXY"/>

第5个控件使用RelativeLayout,多了一个按钮。

    <ImageView 
	android:layout_width="fill_parent"
    	android:layout_height="fill_parent"
    	android:id="@+id/imageview5"
    	android:background="@drawable/guide5_1"
    	android:scaleType="fitXY"/>	
    <tyu.***.TyuButton
        android:id="@+id/go_btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/button_commen"
        android:layout_centerInParent="true"
        android:visibility="visible"/>






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值