backgroundimage скрывает все кнопки в приложении для Android - PullRequest
1 голос
/ 23 апреля 2011

в моем приложении я пытаюсь показать две кнопки и строку заголовка с текстом заголовка над ним. все они были размещены вместе с фоновым изображением. Но я могу видеть только фоновое изображение и другие кнопки, строку заголовка и текст. Ниже приведен макет моей деятельности.

здесь я обозначил фоновый идентификатор imageView как 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>

пожалуйста, скажите мне, где я иду не так .....

1 Ответ

2 голосов
/ 23 апреля 2011

Я думаю, что ваш 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"
    >

Для первого макета следует сделать трюк

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...