android:clipChildren属性
来源:互联网 发布:多益网络二笔试题 编辑:程序博客网 时间:2024/06/04 20:03
参考自:http://www.2cto.com/kf/201608/537822.html
实现功能:
1.底部导航栏的突出图标
2.viewpager一屏多个界面显示
如何实现:
1.底部导航栏的突出图标
注意:需放在根节点 android:clipChildren="false"
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_clip_children" android:layout_width="match_parent" android:layout_height="match_parent" android:clipChildren="false" tools:context="com.sign.viewpagerdemo.ClipChildrenActivity"> <LinearLayout android:layout_width="match_parent" android:layout_height="60dp" android:layout_alignParentBottom="true" android:background="#e7d321" android:orientation="horizontal"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:scaleType="fitCenter" android:src="@mipmap/ic_launcher" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:scaleType="fitCenter" android:src="@mipmap/ic_launcher" /> <ImageView android:layout_width="wrap_content" android:layout_height="90dp" android:layout_gravity="bottom" android:layout_weight="1" android:scaleType="fitCenter" android:src="@mipmap/ic_launcher" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:scaleType="fitCenter" android:src="@mipmap/ic_launcher" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:scaleType="fitCenter" android:src="@mipmap/ic_launcher" /> </LinearLayout></RelativeLayout>
2.viewpager一屏多个界面显示
- 父布局需要
android:clipChildren="false"
- ViewPager宽度
android:layout_width="match_parent"
- 设置margin
android:layout_marginLeft="80dp" android:layout_marginRight="80dp"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.sign.viewpagerdemo.MainActivity"> <LinearLayout android:layout_width="match_parent" android:layout_height="200dp" android:clipChildren="false" android:gravity="center"> <android.support.v4.view.ViewPager android:id="@+id/viewpager3" android:layout_width="match_parent" android:layout_height="200dp" android:layout_marginLeft="80dp" android:layout_marginRight="80dp" android:clipChildren="false" /> </LinearLayout></LinearLayout>
注意:该做法会有一个bug,就是只能滑动中间的那个View,而如果我们想要点着左边或者右边的View滑动怎么办?
解决办法:将父类的touch事件分发至viewPager,linearLayout是ViewPager控件的父容器
linearLayout.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return viewPager.dispatchTouchEvent(event); } });
0 0
- android android:clipChildren属性
- android:clipChildren属性
- android:clipChildren属性
- Android - Layout clipChildren属性
- android:clipChildren属性
- android:clipChildren属性
- android:clipChildren属性
- Android:clipChildren属性
- android:clipChildren属性
- android:clipChildren属性
- Android的clipChildren属性
- android:clipChildren属性
- 【十八】Android:clipChildren属性
- 浅谈android:clipChildren属性
- android:clipChildren属性
- android-clipChildren属性
- Android的android:clipChildren属性
- 神奇的android:clipChildren属性
- 顺序结构线性表
- 防止黑客注入的方法
- kafka启动报错
- visual studio 2013错误:error MSB8020
- Android xutils3同时上传多张图片及上传服务的终止
- android:clipChildren属性
- java enum(枚举)使用详解 + 总结
- itoa 函数
- 线程间的通信 跨线程访问
- [机器学习](八)cs229之主成分分析
- 格子游戏(乙)
- C#绝对路径和相对路径的相互转换
- 关于js中使用call实现继承
- android developer tiny share-201704018