【发布时间】:2022-03-31 18:10:41
【问题描述】:
我关注了this approach,,但使用 FrameLayout 我只能选择使用layout_gravity 定位“橙色”视图,并且当我尝试在图像中解释时,我不知道布局的高度,因为两者用 layout_weight 测量。
我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="onit.radiolisten.MainActivity">
<FrameLayout
android:id="@+id/layout_container_activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- TOP LAYOUT, THE GREEN ONE ON THE IMAGE -->
<LinearLayout
android:id="@+id/layout_top_activity_main"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="2"
android:background="@color/colorPrimary"
android:orientation="vertical"></LinearLayout>
<!-- BOTTOM LAYOUT, THE BLUE ONE ON THE IMAGE -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#e6e6e6">
</RelativeLayout>
</LinearLayout>
<!-- THIS IS THE IMAGE I WANT TO POSITION -->
<ImageView
android:id="@+id/btn_play_radio"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center"
android:src="@drawable/play_icon" />
</FrameLayout>
</LinearLayout>
这只能用 XML 完成吗?
【问题讨论】:
标签: android xml android-layout overlap android-layout-weight