[英]How to make the size of View the same as the size of my custom TextureVIew Android
I have code: 我有代码:
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="#000000"
android:id="@+id/frame">
<View
android:id="@+id/tapView"
android:background="#0000ff"
android:layout_height="fill_parent"
android:layout_width="fill_parent"/>
<com.example.yApp.MyTextureView
android:id="@+id/texture"
android:background="#ff0000"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true">
<--- some code --->
</FrameLayout>
My custom TextureView choose size by code, I need another View (id="tapView") with the same width and height as my custom TextureView and also on the same place on screen. 我的自定义TextureView通过代码选择大小,我需要另一个视图(id =“ tapView”),该视图的宽度和高度与我的自定义TextureView相同,并且也在屏幕上的同一位置。
The problem of my code is that tapView stretches to the full screen and overlaps next FrameLayout 我的代码的问题是tapView会延伸到全屏并与下一个FrameLayout重叠
Try to use ConstraintLayout
, both of these view will have 尝试使用
ConstraintLayout
,这两个视图都将具有
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
The view will have 该视图将具有
app:layout_constraintBottom_toBottomOf="@id/texture"
app:layout_constraintEnd_toEndOf="@id/texture"
matching your view 符合您的观点
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.