您應該考慮使用Android的layout_sum:
因爲我不知道你究竟是如何編碼這不,我只能提供基於假設代碼。我假設您想要按比例將父視圖中的VideoView和ImageView對齊。 (假設您需要30%的空間被ImageView佔用,其餘70%的空間被VideoView佔用)。
可以按如下方式編寫XML文件:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="10"
android:orientation="vertical"
android:layout_gravity="center">
<VideoView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="7"/>
</LinearLayout>
這將嵌入VideoView和ImageView的到的LinearLayout(父視圖)。
你爲什麼標記C#?這是一個Xamarin相關的問題嗎? –
@VadimCaen我正在使用Xamarin,但問題並不是特定語言。我要求一種通用技術,不一定是特定的代碼。 – user2966445
你看過新的ConstraintLayout嗎?這可能是你需要的(即使有其他解決方案)。如果你能展示你想要達成的目標,那將是非常棒的。 –