Android 调整框架布局的大小不会显示所有子项
我有一个扩展框架布局的自定义视图,其中有一些子视图。xml如下所示Android 调整框架布局的大小不会显示所有子项,android,kotlin,resize,visibility,android-framelayout,Android,Kotlin,Resize,Visibility,Android Framelayout,我有一个扩展框架布局的自定义视图,其中有一些子视图。xml如下所示 <com.example.ui.views.DraggableSurfaceViewRenderer xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/l
<com.example.ui.views.DraggableSurfaceViewRenderer xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/localPeerContainer"
android:layout_width="120dp"
android:layout_height="180dp"
android:background="@color/colorPrimary">
<org.webrtc.SurfaceViewRenderer
android:id="@+id/localPeerSurfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/localPeerSpotLight"
android:layout_width="20dp"
android:layout_height="20dp"
app:tint="@color/colorWhite"
android:padding="3dp"
android:layout_margin="4dp"
android:src="@drawable/ic_spot_light"
android:background="@drawable/circle_accent"
android:visibility="gone" />
<ImageView
android:id="@+id/localPeerExitSpotLight"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_close_24dp"
android:background="@drawable/circle_accent"
android:layout_margin="4dp"
android:padding="3dp"
android:layout_gravity="end"
android:visibility="gone"/>
</com.example.ui.views.DraggableSurfaceViewRenderer>
好的,我可以看到localPeerContainer在宽度和高度上与父级匹配,因此1)完成。
但是,我看不到ImageView。
但是,在localPeerContainer更改维度之前的一瞬间,我看到了可见的。最奇怪的是,在ImageViews位置,clickListeners可以正常工作,因为我在这些位置单击,监听器会被触发,尽管ImageView在那里不可见。
我做错了什么
ViewUtils.translationX(localPeerContainer, 0f)
ViewUtils.translationY(localPeerContainer, 0f)
localPeerContainer.layoutParams = FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT
)
localPeerSpotLight.visibility = View.VISIBLE
localPeerExitSpotLight.visibility = View.VISIBLE