Android, проблема с расположением кнопок XML - PullRequest
2 голосов
/ 14 января 2011

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/bkgrnd">
<ScrollView
    android:id="@+id/ScrollView01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:isScrollContainer="true"
    android:scrollbars="vertical"
    android:scrollbarAlwaysDrawVerticalTrack="true">
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">     
        <Spinner
            android:id="@+id/Spinner_Table"
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:drawSelectorOnTop="true"></Spinner>
         <TextView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:textSize="@dimen/help_text_size"
            android:textStyle="bold"
            android:gravity="center"
            android:id="@+id/Blank"></TextView>
        <TextView  
            android:id="@+id/admintable" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"></TextView>
        <Button 
            android:id="@+id/Logout" 
            android:text="@string/Logout" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"></Button>
        </LinearLayout>
</ScrollView>

Все, что я хочу сделать, - это последняя кнопка в этом упражнении, отображаемая в нижней части экрана. Если я переместил кнопку за пределы вида прокрутки, я получил ошибку. Что мне делать?

Ответы [ 2 ]

3 голосов
/ 14 января 2011

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

Также я думаю, это - это то, что вы пытаетесь достичь

Я не могу проверить это прямо сейчас, но альтернатива RelativeLayout должна выглядеть следующим образом:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bkgrnd">
    <Button 
        android:id="@+id/Logout" 
        android:text="@string/Logout" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"></Button>
    <ScrollView
        android:id="@+id/ScrollView01"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_above="@id/Logout"
        android:isScrollContainer="true"
        android:scrollbars="vertical"
        android:scrollbarAlwaysDrawVerticalTrack="true">
        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">     
            <Spinner
                android:id="@+id/Spinner_Table"
                android:layout_height="wrap_content"
                android:layout_width="fill_parent"
                android:drawSelectorOnTop="true"></Spinner>
             <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textSize="@dimen/help_text_size"
                android:textStyle="bold"
                android:gravity="center"
                android:id="@+id/Blank"></TextView>
            <TextView  
                android:id="@+id/admintable" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"></TextView>
        </LinearLayout>
    </ScrollView>
</RelativeLayout>
1 голос
/ 14 января 2011

Что ж, Усман, вы должны реализовать иерархию макетов, как показано ниже

LinearLayout
          |->your ScrollView
          |                  |->Your Linearlayout & then spinner in it etc.etc.(& remove button from this layout)
          |->a new LinearLayout(to hold your button)
                             |->your Logout Button here

и все готово!

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