android - backgroundimage 隐藏了 android 应用程序中的所有按钮

标签 android imageview

在我的应用程序中,我试图显示两个按钮和一个上面有标题文本的标题栏。这些都与背景图像一起放置。但我只能看到背景图像和其他按钮、标题栏和文本。以下是我的 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/

相关文章:

android - 在 picasso 库中,当我的图像加载时,我现在如何触发哪个事件监听器?

java - Android - 将登录信息发送到 MySQL 数据库

c# - 在 Xamarin Android 中将图像从 URL 异步加载到 ImageView

android - 如何将 ImageView 转换成不同的形状?

android - 如何将 Base64 字符串转换为位图图像以在 ImageView 中显示?

android - 如何在 Recyclerview 交错网格布局中使用 Picasso 加载图像之前设置 ImageView 的高度和宽度

java - Imageloader 几张图像到 ViewPager

java - Quicktime 无法播放录制的 mp4 视频文件

java - Android Studio的Gradle Sync(SDK)问题

java - 如何使用编辑文本更新搜索栏