繁体   English   中英

如何使View的大小与我自定义的TextureVIew Android的大小相同

[英]How to make the size of View the same as the size of my custom TextureVIew Android

我有代码:

<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>

我的自定义TextureView通过代码选择大小,我需要另一个视图(id =“ tapView”),该视图的宽度和高度与我的自定义TextureView相同,并且也在屏幕上的同一位置。

我的代码的问题是tapView会延伸到全屏并与下一个FrameLayout重叠

尝试使用ConstraintLayout ,这两个视图都将具有

 app:layout_constraintStart_toStartOf="parent" 
 app:layout_constraintTop_toTopOf="parent"

该视图将具有

 app:layout_constraintBottom_toBottomOf="@id/texture"
 app:layout_constraintEnd_toEndOf="@id/texture"

符合您的观点

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM