Tag: 布局的

什么触发了View的measure()被调用

在我的应用程序中,我的View的onMeasure()覆盖之一有一个无限循环。 从我的onMeasure中的一个断点开始debugging源代码,我可以追踪自己一直到堆栈跟踪到PhoneWindow $ DecorView的measure()(我的View Hierarchy中最高级的类),ViewRoot .performTraversals()。 现在从这里开始,如果我继续走下去,我最终会通过Looper.loop()类中的消息再次调用PhoneWindow $ DecorView的measure()方法。 我在猜测,有些东西已经排好了需要重新测量的信息,就像一个无效的东西。 我的问题是,什么触发一个措施调用需要发生在一个视图? 根据我对布局/度量/绘制过程的理解,只有当在特定视图上调用invalidate()方法时,才会发生这种情况,并且会对该视图执行布局/测量/绘制过程,它的孩子。 我会认为,我的视图层次结构中最顶层的视图会失效。 但是,我已经明确地在每一个无效呼叫中都有一个断点,并且不会以某种无限的方式调用invalidate。 所以我不认为是这样。 是否有另一种方法来触发测量通行证? 内部可能会触发这个? 看到没有什么是无限无效的,我有种想法。

如何以编程方式改变布局的可见性

有方法来改变视图的可见性,但我怎样才能改变在XML中定义的布局的编程可见性? 如何获得布局对象? <LinearLayout android:id="@+id/contacts_type" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:visibility="gone"> </LinearLayout>

从屏幕底部向上滑动布局

我有一个隐藏的视图布局。 在一个button上单击我希望它从底部向上滑动,向上推动整个屏幕内容,非常类似于WhatsApp在聊天屏幕中显示表情符号面板的方式。 我见过SlidingDrawer,不适合我。 它需要一个图像作为在屏幕中心显示的句柄,我不想要这个。 它也滑过现有的屏幕内容,我正在寻找一种方法向上移动现有的内容。 更新1: 我尝试使用Sanket Kachhelabuild议的animation。 但隐藏的布局从不显示。 这是代码。 布局(activity_main.xml): <RelativeLayout android:id="@+id/main_screen" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" android:layout_alignParentTop="true"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" android:layout_centerInParent="true"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Slide up / down" android:layout_alignParentBottom="true" android:onClick="slideUpDown"/> </RelativeLayout> <RelativeLayout android:id="@+id/hidden_panel" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/main_screen"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/app_name" /> </RelativeLayout> 活动(MainActivity.java): package com.example.slideuplayout; import android.app.Activity; import android.os.Bundle; import […]