首页 > 移动平台 > 详细

实现安卓新闻客户端标题栏的左右切换的问题

时间:2016-11-11 20:34:19      阅读:215      评论:0      收藏:0      [点我收藏+]

1.

 <RelativeLayout
        android:id="@id/classify_background"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@mipmap/classify_background"
        android:layout_marginTop="15dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        >
        <Button
            android:id="@id/classifyArrowRigh"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_marginBottom="9dp"
            android:layout_marginRight="10dp"
            android:background="@drawable/classify_arrow_righr_selected"
            />
        <Button
            android:id="@id/classifyArrowLeft"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="10dp"
            android:layout_centerVertical="true"
            android:layout_marginBottom="9dp"
            android:background="@drawable/classify_arrow_left_selected"
            />


        <!--可以滚动的滚动条 android:layout_toLeftOf="@id/classifyArrowRigh"滚动的方向,这句很重要,
        不写都显示不出来 android:scrollbars="none":隐藏滚动条-->
        <HorizontalScrollView
            android:id="@id/horizontalScView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:scrollbars="none"
            android:layout_marginLeft="15dp"
            android:layout_toRightOf="@id/classifyArrowLeft"
            android:layout_toLeftOf="@id/classifyArrowRigh"

            >
            <LinearLayout
                android:id="@id/classify_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="horizontal">

            </LinearLayout>
            <!--要在这个layout里面填充内容也可以在里面用GradView-->

        </HorizontalScrollView>

设置两个button的左右滑动关键代码是:

android:layout_toRightOf="@id/classifyArrowLeft" android:layout_toLeftOf="@id/classifyArrowRigh"
2.在java文件设置单击事件的时候,左右两个按钮都要有各自的滑动距离,而且滑动方向不一样(正负),并不是两个按钮共用一个滑动距离,这样两个按钮实现的就都是一个同向滑动功能了。
private final int flingveLocitypx=800;//右边按钮的滑动距离,android:layout_toLeftOf 
private final int flingveLocitypx1=-800;//左边按钮的滑动距离android:layout_toRightOf
,另外还要设置两个各自的单击事件,调用各自gradview的滑动距离

实现安卓新闻客户端标题栏的左右切换的问题

原文:http://www.cnblogs.com/cmslby/p/6055308.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!