use*_*985 7 android relativelayout android-linearlayout
如果我尝试将图像显示为背景,我的视图出现问题,整个空间和线性布局的第二个子项(彼此相邻的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>
Run Code Online (Sandbox Code Playgroud)
use*_*985 26
有点晚了,但我的问题通过以下代码解决了.
用于ImageView设置我的背景图像,然后在其上显示线性布局.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:contentDescription="@string/my_msg"
android:src="@drawable/my_super_bg_image" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/top_style"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/today"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="some text here"
android:textSize="24sp" />
</RelativeLayout>
</LinearLayout>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
如果有人需要知道更多,我会更新答案.
谢谢.
| 归档时间: |
|
| 查看次数: |
32352 次 |
| 最近记录: |