【发布时间】:2018-11-14 15:02:29
【问题描述】:
如果我尝试将图像显示为背景,我的视图会出现问题,它占用了整个空间,并且线性布局的第二个子项(2 个彼此相邻的 RelativeLayout)不会出现在视图中。
如何将图像设置为背景,保持其他布局元素在其上方?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/globe"
android:layout_gravity="top"
/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
</RelativeLayout>
</LinearLayout>
</LinearLayout>
【问题讨论】:
标签: android android-linearlayout android-relativelayout