[Android学UI之三]实现新浪微博消息页面左右滑动页面方式一(一)
功能:
新浪微博消息页面
使用说明:
先用自定义的一个类:HorizontalPager 实现左右滑动,实现起来比较清爽、简单
HorizontalPager 类在第一篇学UI博客
看图吧!先看效果!!!
![[Android学UI之三]兑现新浪微博消息页面左右滑动页面方式一(一)](http://img.reader8.net/uploadfile/jiaocheng/2014018/2600/2014012612002415026.png)
滑动触发事件。
接下来看代码吧!
界面activity:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="50dip" android:background="@drawable/titlebar_bg_nor" android:gravity="top" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="70dip" android:orientation="horizontal" > <ImageButton android:id="@+id/btn_1" style="@style/titleIcon" android:background="@drawable/msg_group_at" android:onClick="onClick1" /> <ImageButton android:id="@+id/btn_2" style="@style/titleIcon" android:background="@drawable/msg_group_comment" android:onClick="onClick2" /> <ImageButton android:id="@+id/btn_3" style="@style/titleIcon" android:background="@drawable/msg_group_message" android:onClick="onClick3" /> <ImageButton android:id="@+id/btn_4" style="@style/titleIcon" android:background="@drawable/msg_group_notification" android:onClick="onClick4" /> </LinearLayout> <ImageView android:id="@+id/imageView" android:layout_width="20dip" android:layout_height="2dip" android:layout_marginLeft="80dip" android:layout_marginBottom="3dip" android:background="@drawable/title_bar_mark" /> </LinearLayout> <com.bbswp.demo.view.HorizontalPager android:id="@+id/horizontal_pager" android:layout_width="fill_parent" android:layout_height="0px" android:layout_gravity="bottom" android:layout_weight="1" > <TextView android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="我是@页面" android:textSize="24dip" android:textStyle="bold" /> <TextView android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="我是消息页面" android:textSize="24dip" android:textStyle="bold" /> <TextView android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="我是私信页面" android:textSize="24dip" android:textStyle="bold" /> <TextView android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="我是通知页面" android:textSize="24dip" android:textStyle="bold" /> </com.bbswp.demo.view.HorizontalPager></LinearLayout>
如果不想使用android.support.v4.view 包,可以使用此方法来实现滑动功能了!
当然,后面也会使用android.support.v4.view包来实现此功能,分享给大家!!!
不能少了源码分享给大家的!
欢迎大家下载,一起学习交流!!!
下载地址:http://download.csdn.net/detail/hudan2714/4809950