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