FrameLayout 的子View 设置 top 值

来源:互联网 发布:banner图片轮播js代码 编辑:程序博客网 时间:2024/05/16 07:28

FrameLayout 的子View 设置 top 值。


    可以通过重写FrameLayout 的 onLayout 方法来实现。
    TopContentHeight 是top的值。

@Overrideprotected void onLayout(boolean changed, int left, int top, int right,int bottom) {super.onLayout(changed, left, top, right, bottom);if(changed) {final int count = getChildCount();for(int i = 0; i < count; i++) {View child = getChildAt(i);if(child instanceof FullScreenHandlerView) {int width = child.getMeasuredWidth();                        int height = child.getMeasuredHeight();child.layout(0, TopContentHeight, width, TopContentHeight + height);break;}}Log.i(LOGTAG, "changed========="+changed);}}



原创粉丝点击