android技巧:神奇的android:clipChildren属性

前言:

今天在看微博的时候,发现了android:clipChildren属性的这么一个属性,感觉挺有意思的,对今后布局的搭建会很有帮助,特地研究了一下他的实现形式。

正文:

效果图:

之前大家实现上图中下部标题栏的思路是什么呢?大多数情况下,自己是在建立个RelativeLayout,今天看到android:clipChildren属性这个属性之后,才发现,之前的做法是多么的愚蠢!!

代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width
="match_parent"
    android:layout_height
="match_parent"
    android:clipChildren
="false"
    android:orientation
="vertical" >

    <android.support.v4.view.ViewPager
        
android:id="@+id/view_pager"
        android:layout_width
="match_parent"
        android:layout_height
="0dip"
        android:layout_weight
="1.0" />

    <LinearLayout
        
android:layout_width="match_parent"
        android:layout_height
="48dip"
        android:background
="#B0C4DE"
        android:orientation
="horizontal" >

        <ImageView
            
android:layout_width="0dip"
            android:layout_height
="fill_parent"
            android:layout_weight
="1.0"
            android:scaleType
="fitCenter"
            android:src
="@mipmap/ic_launcher
" />

        <ImageView
            
android:layout_width="0dip"
            android:layout_height
="fill_parent"
            android:layout_weight
="1.0"
            android:scaleType
="fitCenter"
            android:src
="@mipmap/ic_launcher" />

        <ImageView
             
android:layout_width="0dip"
            android:layout_height
="64dip"
            android:layout_gravity
="bottom"
            android:layout_weight
="1.0"
            android:scaleType
="fitCenter"
            android:src
="@mipmap/ic_launcher" />

        <ImageView
            
android:layout_width="0dip"
            android:layout_height
="fill_parent"
            android:layout_weight
="1.0"
            android:scaleType
="fitCenter"
            android:src
="@mipmap/ic_launcher" />

        <ImageView
            
android:layout_width="0dip"
            android:layout_height
="fill_parent"
            android:layout_weight
="1.0"
            android:scaleType
="fitCenter"
            android:src
="@mipmap/ic_launcher" />
    </LinearLayout>

</LinearLayout>

当不在爷爷控件中设置android:clipChildren属性的时候,效果图为下图:

 

所以个人觉得,在实际的开发过程中,这个属性的用处还是大大滴!!

android:clipChildren的意思:是否限制子View在其范围内

原文博主还提到了这样一句话,在做动画的时候非常有用!!!好,就说到这里,希望大家多多交流,共同进步!

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值