温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

clipToPadding与clipChildren在Android 中有什么不同

发布时间:2020-12-07 16:36:29 来源:亿速云 阅读:176 作者:Leah 栏目:移动开发

本篇文章给大家分享的是有关clipToPadding与clipChildren在Android 中有什么不同,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

1.对于clipToPadding 默认是true, 这个属性一般都是viewgrounp对象才会用到, 他的意思就是 对于padding 所占的尺寸大小也绘制 其他的item的view,

2.对于clipChildren 默认是true,这个属性是让子view不受父view大小的限制,可以超过父view的宽高,延伸到周围view内部

下面放入效果图:

clipToPadding与clipChildren在Android 中有什么不同

第一个布局是:viewpager 让两边的缩进的同时让其他的也显示一部分,这种效果,就会用到 clipToPadding = false属性

clipToPadding与clipChildren在Android 中有什么不同

这个布局就用到了clipChildren = false,能让flatbutton从上面布局延伸到周围的布局内部而不被覆盖,例如下面的布局也是

clipToPadding与clipChildren在Android 中有什么不同

以上基本都是这两个属性的区别;例子

<&#63;xml version="1.0" encoding="utf-8"&#63;>
<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="@drawable/ic_launcher" />

  <ImageView
   android:layout_width="0dip"
   android:layout_height="fill_parent"
   android:layout_weight="1.0"
   android:scaleType="fitCenter"
   android:src="@drawable/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="@drawable/ic_launcher" />

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

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

</LinearLayout>

以上就是clipToPadding与clipChildren在Android 中有什么不同,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI