在我的应用程序中,我试图显示两个按钮和一个带有标题文本的标题栏。这些都与背景图像一起放置。但我只能看到背景图像和其他按钮,标题栏和文本。以下是我的活动布局。
这里我将背景imageView id表示为bgd。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView android:id="@+id/bgd"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:src="@drawable/startingpage">
</ImageView>
<LinearLayout android:id="@+id/linearLayout1"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<ImageView android:id="@+id/title"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/applicationbar">
</ImageView>
<TextView android:id="@+id/titletext"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="2dip"
android:layout_gravity="center"
android:layout_marginLeft="80dip">
</TextView>
</LinearLayout>
<ImageButton android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dip"
android:layout_marginLeft="20dip"
android:id="@+id/add"
android:src="@drawable/addrestingspot">
</ImageButton>
<ImageButton android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:layout_marginLeft="20dip"
android:id="@+id/search"
android:src="@drawable/search">
</ImageButton>
</LinearLayout>
请告诉我我哪里错了.....
答案 0 :(得分:2)
我认为你的ImageView正在“吃掉”所有空间并将其余元素推到底部。由于您没有滚动条,因此无法看到它们。您应该在第一个LinearLayout(顶级一个)中使用背景图像。类似的东西:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/startingpage"
>
对于第一个布局应该做的诀窍