Android中利用clipchildren属性来完成子视图是否在控制范围内

来源:互联网 发布:php直播间源码 编辑:程序博客网 时间:2024/04/28 17:38

clipchildren属性:是否限制子view在范围内,默认为true,
先来看一下效果图,当我们想要达到以下的效果的时候,应该怎么做呢?

这里写图片描述

其实很简单的,我们来写一下布局文件,

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:clipChildren="false">    <LinearLayout        android:layout_margin="100dp"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:background="#0ff"        android:orientation="vertical">        <ImageView            android:id="@+id/iv_icon"            android:layout_width="60dp"            android:layout_height="60dp"            android:layout_gravity="center"            android:layout_marginTop="-40dp"            android:src="@mipmap/ic_launcher" />        <TextView            android:id="@+id/tv1"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_margin="10dp"            android:text="测试文字-测试文字" />        <TextView            android:id="@+id/tv2"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_margin="10dp"            android:text="测试文字-测试文字" />    </LinearLayou</RelativeLayout>

首先这个属性的使用

必须在根视图中,子试图外面必须有一个包裹的视图才可以。

本人菜鸟一个,有什么不对的地方希望大家指出评论,大神勿喷,希望大家一起学习进步!

2 0