Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android,xml按钮布局问题_Android_Xml_Button - Fatal编程技术网

android,xml按钮布局问题

android,xml按钮布局问题,android,xml,button,Android,Xml,Button,xmlns:android=”http://schemas.android.com/apk/res/android" android:orientation=“垂直” android:layout\u width=“fill\u parent” android:layout\u height=“fill\u parent” android:background=“@drawable/bkgrnd”> 我只想在视图底部显示此活动的最后一个按钮。如果将按钮移到滚动视图外,则会出现错误。我该怎么办

xmlns:android=”http://schemas.android.com/apk/res/android"
android:orientation=“垂直”
android:layout\u width=“fill\u parent”
android:layout\u height=“fill\u parent”
android:background=“@drawable/bkgrnd”>


我只想在视图底部显示此活动的最后一个按钮。如果将按钮移到滚动视图外,则会出现错误。我该怎么办?

尝试使用一个
RelativeLayout
,一开始有点难,但功能非常强大

我也认为这是你努力实现的目标

我现在无法测试它,但RelativeLayout替代方案应该如下所示:

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>

嗯,乌斯曼,你应该做的是实现你的布局层次结构,如下所示

<?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>

你完了

不,我把屏幕弄乱了,标题都重叠了,按钮也不见了,有时我在玩相对布局…有没有其他的方法我添加了一个链接到另一个解决方案,也许可以帮助你。正如我所说,我现在无法测试我的相对布局解决方案,但我在项目中使用了类似的东西,并且正确地设置了它。我想我发现了一个问题,是否有必要将id为空的TextView的高度设置为“fill\u parent”?我更新了我的相对布局解决方案,将其更改为包装内容
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