Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.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 不显示带有ScrollView的最后两个按钮_Android_Xml_Scrollview - Fatal编程技术网

Android 不显示带有ScrollView的最后两个按钮

Android 不显示带有ScrollView的最后两个按钮,android,xml,scrollview,Android,Xml,Scrollview,我是android的新手。我希望在屏幕顶部有一个ImageView页面,在页面底部有4个按钮,在页面中间有一个frameLayout。我已经完成了在FrameLayout中加载xml文件的工作。它包含滚动视图和10个按钮。但当我运行程序时,最后两个按钮并没有显示在滚动页面后的页面上 有人能帮我吗 main.xml: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schem

我是android的新手。我希望在屏幕顶部有一个ImageView页面,在页面底部有4个按钮,在页面中间有一个frameLayout。我已经完成了在FrameLayout中加载xml文件的工作。它包含滚动视图和10个按钮。但当我运行程序时,最后两个按钮并没有显示在滚动页面后的页面上

有人能帮我吗

main.xml:

<?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/background">

    <ImageView
         android:id="@+id/yellowbar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/smallyelowbar"
        android:adjustViewBounds="true"
        android:scaleType="fitXY"
        android:layout_alignParentTop="true"/> 
<RelativeLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="0"
    android:layout_gravity="bottom"
    android:layout_below="@id/yellowbar">
        <FrameLayout
            android:id="@+id/frameLayout"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"/>

</RelativeLayout>
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_alignParentBottom="true">
        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/topmenu"
            android:adjustViewBounds="true"
            android:scaleType="fitXY"/>
                <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_alignParentBottom="true">

        <Button android:id="@+id/btn1"
            android:layout_width="0dip"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:background="@drawable/more_selector"/>
        <Button 
            android:id="@+id/btn2"
            android:layout_width="0dip"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:background="@drawable/contact_selector"/>
        <Button android:id="@+id/btn3"
            android:layout_width="0dip"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:background="@drawable/product_selector"/>
        <Button android:id="@+id/btn4"
            android:layout_width="0dip"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:background="@drawable/introduce_selector"/>
        </LinearLayout>
        </LinearLayout>
</RelativeLayout>

scrooll.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="fill_parent" 
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical">

<ScrollView 
android:layout_width="fill_parent" 
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<Button
    android:id="@+id/btn1_product"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_marginRight="10dp"
    android:layout_marginTop="7dp"
    android:background="@drawable/product_sub_selector"
    android:text="@string/btn1_product"
    android:textColor="@color/white"
    android:textSize="10sp"/>
<Button
    android:id="@+id/btn2_product"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_marginRight="10dp"
    android:layout_marginTop="7dp"
    android:background="@drawable/product_sub_selector"
    android:textColor="@color/white"
    android:text="@string/btn2_product"
    android:layout_below="@id/btn1_product"
    android:textSize="10sp"/>
<Button
    android:id="@+id/btn3_product"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_marginRight="10dp"
    android:layout_marginTop="7dp"
    android:background="@drawable/product_sub_selector"
    android:textColor="@color/white"
    android:text="@string/btn3_product"
    android:layout_below="@id/btn2_product"
    android:textSize="10sp"/>
<Button
    android:id="@+id/btn4_product"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_marginRight="10dp"
    android:layout_marginTop="7dp"
    android:background="@drawable/product_sub_selector"
    android:textColor="@color/white"
    android:text="@string/btn4_product"
    android:layout_below="@id/btn3_product"
    android:textSize="12sp"/>
<Button
    android:id="@+id/btn5_product"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_marginRight="10dp"
    android:layout_marginTop="7dp"
    android:background="@drawable/product_sub_selector"
    android:textColor="@color/white"
    android:text="@string/btn5_product"
    android:layout_below="@id/btn4_product"
    android:textSize="12sp"/>
<Button
    android:id="@+id/btn6_product"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_marginRight="10dp"
    android:layout_marginTop="7dp"
    android:background="@drawable/product_sub_selector"
    android:textColor="@color/white"
    android:text="@string/btn6_product"
    android:layout_below="@id/btn5_product"
    android:textSize="12sp"/>
<Button
    android:id="@+id/btn7_product"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_marginRight="10dp"
    android:layout_marginTop="7dp"
    android:background="@drawable/product_sub_selector"
    android:textColor="@color/white"
    android:text="@string/btn7_product"
    android:layout_below="@id/btn6_product"
    android:textSize="12sp"/>
<Button
    android:id="@+id/btn8_product"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_marginRight="10dp"
    android:layout_marginTop="7dp"
    android:background="@drawable/product_sub_selector"
    android:textColor="@color/white"
    android:text="@string/btn8_product"
    android:layout_below="@id/btn7_product"
    android:textSize="12sp"/>
<Button
    android:id="@+id/btn9_product"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_marginRight="10dp"
    android:layout_marginTop="7dp"
    android:background="@drawable/product_sub_selector"
    android:textColor="@color/white"
    android:text="@string/btn9_product"
    android:layout_below="@id/btn8_product"
    android:textSize="12sp"/>
<Button
    android:id="@+id/btn10_product"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_marginRight="10dp"
    android:layout_marginTop="7dp"
    android:background="@drawable/product_sub_selector"
    android:textColor="@color/white"
    android:text="@string/btn10_product"
    android:layout_below="@id/btn9_product"
    android:textSize="12sp"/>

</RelativeLayout>
</ScrollView>

</LinearLayout>

谢谢您的帮助。

尝试将“包裹内容”添加到高度

    <ScrollView 
         android:layout_width="fill_parent"
        android:layout_height="wrap_content" > </ScrollView>


在第一个xml的最后一个
线性布局中添加
android:weightSum=4

将RelativeLayout转换为线性布局,它会起作用。

我不确定,但我认为线性布局应该在滚动视图中。ScrollView中的RelativeLayout不应该是必需的。
RelativeLayout
是必需的,@Day<代码>滚动视图
只能容纳一个元素。感谢您的快速回复。我删除了LinearLayout,但没有显示最后两个按钮。我认为如果我将相对布局改为线性布局,就不能解决问题。我想最后两个按钮隐藏在页面底部的按钮后面。你们能发布一个你们想实现的屏幕截图吗。我写下新的答案,加上一张图片,我说我想要什么。ThanksI更改了ScrollView的高度以包装程序未解决的内容:(我如何解决此问题?)ThanksI认为问题在于main.xml中的LinearLayout。但在问题解决之前,我不知道如何更改此高度:(我看到main.xml的预览页面,我看到FrameLayout位于ImageView的下方,直到页面底部和按钮位于FrameLayout的上方。我认为,我应该将FrameLayout设置在页面中间ImageView和按钮之间。请告诉我如何实现此功能???