Android Clipchildren Attribute Example detailed _android

Source: Internet
Author: User

Objective

A few days ago, a blog was recommended on Weibo to find this attribute when reading his article. Some properties are not commonly used, but they are very useful when needed, so an example is used, just to share with you.




Body

First, the effect chart

When you see this picture, you can think about how you would achieve this effect if it were you. Immediately thought of using relativelayout? No,no,no,,,

Second, the implementation of the Code

<?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="@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>


Code Description:

1, only in the root node set Android:clipchildren to False, the default is true.



2, can through android:layout_gravity control over how the part of the display.



3, Android:clipchildren meaning: whether to limit the child view within its scope.



End:


The above example is very useful when doing the Android animation, the need friend can refer to.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.