无法获取clipChildren = false属性工作 [英] Can't get clipChildren=false attribute to work

查看:1762
本文介绍了无法获取clipChildren = false属性工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个红色的 RelativeLayout的含有较高的黄的LinearLayout

I have a red RelativeLayout containing a higher yellow LinearLayout.

为了使整个的LinearLayout 可见,我设置安卓clipChildren =假,但这不能按预期:

In order to make the whole LinearLayout visible, I set android:clipChildren="false", but this does not work as expected:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="44dp"
    android:background="#FFFF00"
    android:clipChildren="false" >

    <LinearLayout
        android:layout_width="50dp"
        android:layout_height="100dp"
        android:background="#FF0000"
        android:orientation="vertical" >

    </LinearLayout>

</RelativeLayout>

  • 安卓clipChildren =真正的
    • with android:clipChildren="true":
    • 与红色的LinearLayout 裁剪预期

      • 安卓clipChildren =假

      其中的LinearLayout 高度修剪,并在布局中设置宽度不尊重。

      where the LinearLayout height is clipped, and the width set in the layout is not respected.

      怎么了?

      修改

      如果我包装容器在的LinearLayout 有两个维度匹配它的父,我得到了相同的结果(我检查了的LinearLayout容器的容器充满整个屏幕)。

      If I wrap the container in a LinearLayout with both dimensions matching its parent, I get the same result (I checked that the LinearLayout container's container fill the whole screen).

      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          android:layout_width="match_parent"
          android:layout_height="match_parent">
      
          <RelativeLayout
              android:layout_width="match_parent"
              android:layout_height="44dp"
              android:background="#FFFF00"
              android:clipChildren="false" >
      
              <LinearLayout
                  android:layout_width="50dp"
                  android:layout_height="100dp"
                  android:background="#FF0000"
                  android:orientation="vertical" >
              </LinearLayout>
          </RelativeLayout>
      
      </LinearLayout>
      

      编辑2

      如果我把安卓clipChildren =假属性在父LinearLayout中,我得到如下:

      If I put the android:clipChildren="false" attribute in the parent LinearLayout, I get the following:

      推荐答案

      安卓clipChildren =假让每一个孩子画自己的范围之外,内父母。它不会让孩子的父母本身之外的借鉴。对于您需要设置机器人:clipChildren =假的祖父母(以及)

      android:clipChildren="false" allows each child to draw outside of its own bounds, within the parent. It doesn't allow children to draw outside of the parent itself. For that you would need to set android:clipChildren="false" on the grandparent (as well).

      我想你看到的颜色是什么,只是因为颜色有没有固有的界限。如果没有什么剪裁他们,色彩永远走。我的理论是,如果你使用,也就是说,一个拉伸的1x1像素的图像,而不是颜色,事情会有所不同。

      I think what you're seeing with the colors is just because colors have no inherent bounds. If there is nothing clipping them, colors go forever. My theory is that if you used, say, a stretched 1x1 px image instead of a color, things would be different.

      这篇关于无法获取clipChildren = false属性工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆