Android - кнопка XML пропала? - PullRequest
1 голос
/ 14 января 2011
<?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"
    android:background="@drawable/bkgrnd">
    <RelativeLayout
        android:id="@+id/RelativeLayout01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >
        <ImageView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/ImageView_MenuHeader"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/logo"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"></ImageView>
        <TextView
            android:id="@+id/TextView01"
            android:layout_height="wrap_content"
            android:text="@string/admin"
            android:textSize="@dimen/screen_title_size"
            android:shadowDx="0"
            android:shadowDy="0"
            android:shadowRadius="10"
            android:layout_width="wrap_content"
            android:layout_gravity="fill_horizontal|center"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:shadowColor="@android:color/white"
            android:textColor="@color/title_color"></TextView>
        <ImageView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/ImageView_MenuHeader2"
            android:layout_height="wrap_content"
            android:src="@drawable/logo"
            android:layout_gravity="right|center_vertical"
            android:layout_width="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"></ImageView>
    </RelativeLayout>    
    <ScrollView
        android:id="@+id/ScrollView01"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        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="wrap_content">     
            <Spinner
                android:id="@+id/Spinner_Table"
                android:layout_height="wrap_content"
                android:layout_width="fill_parent"
                android:drawSelectorOnTop="true"></Spinner>
             <TextView
                android:layout_width="wrap_content"
                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
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent">  
             <Button 
                android:id="@+id/Logout" 
                android:text="@string/Logout" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"></Button>
    </RelativeLayout>
 </LinearLayout>

Все вышеперечисленное xml находится внутри линейного макета ... Проблема в том, что в административной таблице текстового представления тоже записываются данные, в приложении отображается большой объем данных ... данные отображаются нормально ... однако, когда пользователь прокручивает экран до конца, он должен увидеть кнопку выхода из системы, но она не отображается?

Ответы [ 2 ]

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

Попробуйте установить для ScrollView layout_height что-то статичное, например 60dp, и установите для layout_weight значение 1.0, что приведет к его расширению до максимума без отключения экрана.

<ScrollView
    android:id="@+id/ScrollView01"
    android:layout_width="fill_parent"
    android:layout_height="60dp"
    android:layout_weight="1.0"
    android:isScrollContainer="true"
    android:scrollbars="vertical"
    android:scrollbarAlwaysDrawVerticalTrack="true">
    ...
</ScrollView>

Это, однако, должно привести к тому, что кнопка «Выход» все время будет отображаться под ScrollView.

. Чтобы кнопка появилась в нижней части ScrollView, попробуйте переместить RelativeLayout.внутри ScrollView и вложив их в другой LinearLayout примерно так:

<?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"
    android:background="@drawable/bkgrnd">
    <RelativeLayout
        android:id="@+id/RelativeLayout01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >
        ... your header views ...
    </RelativeLayout>    
    <ScrollView
        android:id="@+id/ScrollView01"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:isScrollContainer="true"
        android:scrollbars="vertical"
        android:scrollbarAlwaysDrawVerticalTrack="true">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">     
            <LinearLayout
                android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content">     
                ... data you load ...
            </LinearLayout>
            <RelativeLayout
                android:orientation="vertical"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent">  
                 <Button 
                    android:id="@+id/Logout" 
                    android:text="@string/Logout" 
                    android:layout_width="wrap_content" 
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"></Button>
            </RelativeLayout>
        </LinearLayout>
    </ScrollView>
 </LinearLayout>
0 голосов
/ 14 января 2011

Некоторые комментарии:

Вам не нужно определять виджеты следующим образом:

 <Button 
                android:id="@+id/Logout" 
                android:text="@string/Logout" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"></Button>

Вы можете сделать это так:

 <Button 
                android:id="@+id/Logout" 
                android:text="@string/Logout" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"/>

Из моегоС точки зрения, проблема, с которой вы столкнулись, заключается в том, что ScrollView занимает все оставшееся пространство.

Попробуйте определить RelativeLayout сначала с помощью Button и скажите ScrollView как android:layout_above the RelativeLayout.

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