在我的应用程序中,我试图显示两个按钮和一个上面有标题文本的标题栏。这些都与背景图像一起放置。但我只能看到背景图像和其他按钮、标题栏和文本。以下是我的 Activity 布局。
这里我已经将背景 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>
请告诉我哪里错了.....
最佳答案
我认为您的 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"
>
对于第一个布局应该可以解决问题
关于android - backgroundimage 隐藏了 android 应用程序中的所有按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5764844/