LinearLayout animate()剪辑视图,clipChildren不起作用

我试图为container LinearLayout(20dp)和btnbutton(20dp)(向右移动)设置animation,但是在main LinearLayout(40dp)的整个宽度之后它们会被裁剪。 我已经尝试过clipChildren="false" ,但它不起作用。 我不能使用match_parent大小的布局,因为它是一个覆盖的应用程序,将阻止后面的触摸。

有任何想法吗?

我的布局:

 <LinearLayout android:id="@+id/main" android:layout_width="wrap_content" android:layout_height="wrap_content" android:clipChildren="false" android:clipToPadding="false" > <LinearLayout android:id="@+id/container" android:layout_width="20dp" android:layout_height="80dp" android:clipChildren="false" android:clipToPadding="false" > </LinearLayout> <ImageButton android:id="@+id/btn" android:layout_width="20dp" android:layout_height="80dp" android:padding="0dp" android:background="@drawable/btn" /> </LinearLayout> 

我的(简体)代码:

 super.onCreate(); windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); params = new WindowManager.LayoutParams( LayoutParams.WRAP_CONTENT, //can't have MATCH_PARENT LayoutParams.WRAP_CONTENT, //can't have MATCH_PARENT WindowManager.LayoutParams.TYPE_SYSTEM_ALERT | WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT); LayoutInflater inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE); main = (LinearLayout) inflater.inflate(R.layout.main,null); btn = (ImageButton)main.findViewById(R.id.btn); container = (LinearLayout)main.findViewById(R.id.container); btn.setOnClickListener(onClickListener); windowManager.addView(main, params); } 

animation代码:

 public void onClick(View v) { btn.animate().xBy(100f).setDuration(2000); container.animate().xBy(100f).setDuration(2000); } 

Solutions Collecting From Web of "LinearLayout animate()剪辑视图,clipChildren不起作用"