【发布时间】:2011-12-18 20:51:32
【问题描述】:
我有一个带有背景图像的屏幕,底部有两个按钮。我正在使用类似这样的代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="0dip" android:layout_weight="1"
android:orientation="vertical" android:background="@drawable/mainbg">
</LinearLayout>
<ImageButton android:layout_height="wrap_content"
android:background="#FF000000" android:src="@drawable/button1"
android:padding="5dp"
android:id="@+id/ImageButton1" android:layout_width="fill_parent">
</ImageButton>
<ImageButton android:src="@drawable/button2" android:background="#FF000000" android:id="@+id/ImageButton2"
android:layout_width="fill_parent" android:focusable="true" android:saveEnabled="false" android:layout_height="wrap_content">
</ImageButton>
<TextView android:text="mywebsite.com" android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
</LinearLayout>
在此代码中,背景屏幕被粉碎以适应按钮未使用的剩余屏幕空间。也就是说,两个按钮占用了20%的屏幕空间,然后图片就被砸成了剩下的80%。
我的问题: 有没有办法制作某种分层效果,以便我的按钮位于背景图像上方的图层上?
【问题讨论】:
-
检查你的主容器,即你的主布局是包含你的命名空间“xmlns”标签并包含你所有的视图,所以最好在这个布局中设置背景以获得你的全屏背景可绘制的图像。