Android界面按钮隐藏了我的应用程序的底部

Android界面按钮隐藏了我的应用程序的底部,android,Android,我不知道怎么解决这个问题。它在预览中显示良好,当我运行最后一个按钮时,界面会隐藏它。当我添加ScrollView时也会发生这种情况——不是这样 我也不想隐藏Android的按钮界面 没有滚动视图 带滚动视图 XML 我认为您应该使用填充父容器,而不是匹配父容器的高度。你的手机会认为它必须填满整个屏幕。但这并不是必需的,因为您的Android按钮(标题)界面。首先,您在线性布局中使用的weightsum是无用的。 现在,为什么在手机中看不到按钮而在预览中看到,是因为在预览中,您隐藏了操作栏。

我不知道怎么解决这个问题。它在预览中显示良好,当我运行最后一个按钮时,界面会隐藏它。当我添加ScrollView时也会发生这种情况——不是这样

我也不想隐藏Android的按钮界面

没有滚动视图

带滚动视图

XML



我认为您应该使用填充父容器,而不是匹配父容器的高度。你的手机会认为它必须填满整个屏幕。但这并不是必需的,因为您的Android按钮(标题)界面。

首先,您在
线性布局中使用的
weightsum
是无用的。 现在,为什么在手机中看不到按钮而在预览中看到,是因为在预览中,您隐藏了
操作栏
。 现在,如果要在布局中显示按钮,有两种方法:-

  • 您需要调整视图的大小并使其变小。(不可靠,不推荐使用

  • 您需要在
    滚动视图中显示按钮上方的视图。
    要有效地执行此操作,请按照您在上述代码中编写的方式,提供scrollview
    weight=1
    和按钮

  • `

    
    
    `

    我在这里做的是,在
    线性布局中添加
    滚动视图
    两个按钮
    Scrollview
    提供了
    android:layout\u weight=“1”

    现在所发生的是,按钮将占用所需的空间,其余空间将由
    滚动视图
    覆盖

    将线性布局放在滚动视图中。因为每个手机都有不同的屏幕尺寸,所以最好将其放在滚动视图中

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context="com.example.tiagosilva.amob_android.ContactUsFragment"
    android:background="@color/AMOB_gray">
    
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:padding="20dp"
        android:weightSum="3">
    
        <TextView
            android:id="@+id/textView2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="serif"
            android:text="AMOB Headquarters"
            android:textAppearance="@style/TextAppearance.AppCompat"
            android:textColor="@android:color/white"
            android:textStyle="bold" />
    
        <TextView
            android:id="@+id/textView3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="serif"
            android:text="Rua Padre Domingos Joaquim Pereira,1249"
            android:textAppearance="@style/TextAppearance.AppCompat"
            android:textColor="@android:color/white" />
    
        <TextView
            android:id="@+id/textView4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="serif"
            android:text="4760-563 Louro"
            android:textAppearance="@style/TextAppearance.AppCompat"
            android:textColor="@android:color/white"
            android:background="@color/AMOB_gray"/>
    
        <TextView
            android:id="@+id/textView5"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="serif"
            android:text="Vila Nova de Famalicão, Portugal"
            android:textAppearance="@style/TextAppearance.AppCompat"
            android:textColor="@android:color/white" />
    
        <TextView
            android:id="@+id/textView7"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="serif"
            android:text="Phone: (+351) 252 330 900"
            android:textAppearance="@style/TextAppearance.AppCompat"
            android:textColor="@android:color/white" />
    
        <TextView
            android:id="@+id/textView8"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="serif"
            android:text="Fax: (+351) 252 376 887"
            android:textAppearance="@style/TextAppearance.AppCompat"
            android:textColor="@android:color/white" />
    
        <TextView
            android:id="@+id/textView9"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="serif"
            android:text="E-mail: comercial@amob.pt"
            android:textAppearance="@style/TextAppearance.AppCompat"
            android:textColor="@android:color/white" />
    
        <TextView
            android:id="@+id/textView6"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="serif"
            android:text="GPS: 41º 26'.16''N / 8º32'31.89''W"
            android:textAppearance="@style/TextAppearance.AppCompat"
            android:textColor="@android:color/white" />
    
    
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/gps_amob"
            android:id="@+id/gps_map"
            android:layout_weight="3"
            android:layout_marginTop="10dp"
            android:scaleType="fitXY"/>
    
        <Button
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:id="@+id/btn_emailUs"
            android:background="@drawable/round_buttons"
            android:layout_marginTop="10dp"
            android:text="Email us">
        </Button>
    
        <Button
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:id="@+id/btn_callUs"
            android:background="@drawable/round_buttons_green"
            android:layout_marginTop="10dp"
            android:text="Call Us">
        </Button>
    
    </LinearLayout>
    </ScrollView>
    </FrameLayout>
    
    
    
    这样的办法应该行得通。
    希望这有帮助

    垂直
    线性布局的布局规则是“使用要求的高度、填充和边距,一个接一个地垂直堆叠所有内容”。在该
    垂直
    线性布局中有12个小部件。所有内容的高度均为
    wrap\u content
    。有些有利润。
    LinearLayout
    本身具有填充。如果所有这些的总和大于屏幕的高度,其中一些将无法安装在屏幕上。您可以使用
    滚动视图
    允许用户滚动查看所有内容。然而,使用
    ScrollView
    并不会使所有内容都像魔术一样合拍。它不是ScrollView。。。。我是在这个问题上说的……我知道。我在评论中解释了这一点。你的问题是,你有太多的东西可用的屏幕空间。但与滚动查看它应该一切。。。但它不是“但在滚动视图中,它应该包含所有内容”-这不是
    ScrollView
    的功能。填充父项在哪里?在线性布局标签中?为什么有权重和3?我不知道。。。我不知道我在做什么我用它把图像缩小了。他想一直显示底部的按钮。您的布局将隐藏按钮并使其可滚动。检查我的答案。
    <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
    
            <ScrollView
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1">
    
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:padding="20dp">
    
                    <TextView
                        android:id="@+id/textView2"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:fontFamily="serif"
                        android:text="AMOB Headquarters"
                        android:textAppearance="@style/TextAppearance.AppCompat"
                        android:textColor="@android:color/white"
                        android:textStyle="bold" />
    
                    <TextView
                        android:id="@+id/textView3"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:fontFamily="serif"
                        android:text="Rua Padre Domingos Joaquim Pereira,1249"
                        android:textAppearance="@style/TextAppearance.AppCompat"
                        android:textColor="@android:color/white" />
    
                    <TextView
                        android:id="@+id/textView4"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@color/AMOB_gray"
                        android:fontFamily="serif"
                        android:text="4760-563 Louro"
                        android:textAppearance="@style/TextAppearance.AppCompat"
                        android:textColor="@android:color/white" />
    
                    <TextView
                        android:id="@+id/textView5"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:fontFamily="serif"
                        android:text="Vila Nova de Famalicão, Portugal"
                        android:textAppearance="@style/TextAppearance.AppCompat"
                        android:textColor="@android:color/white" />
    
                    <TextView
                        android:id="@+id/textView7"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:fontFamily="serif"
                        android:text="Phone: (+351) 252 330 900"
                        android:textAppearance="@style/TextAppearance.AppCompat"
                        android:textColor="@android:color/white" />
    
                    <TextView
                        android:id="@+id/textView8"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:fontFamily="serif"
                        android:text="Fax: (+351) 252 376 887"
                        android:textAppearance="@style/TextAppearance.AppCompat"
                        android:textColor="@android:color/white" />
    
                    <TextView
                        android:id="@+id/textView9"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:fontFamily="serif"
                        android:text="E-mail: comercial@amob.pt"
                        android:textAppearance="@style/TextAppearance.AppCompat"
                        android:textColor="@android:color/white" />
    
                    <TextView
                        android:id="@+id/textView6"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:fontFamily="serif"
                        android:text="GPS: 41º 26'.16''N / 8º32'31.89''W"
                        android:textAppearance="@style/TextAppearance.AppCompat"
                        android:textColor="@android:color/white" />
    
    
                    <ImageView
                        android:id="@+id/gps_map"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="10dp"
                        android:scaleType="fitXY"
                        android:src="@drawable/gps_amob" />
                </LinearLayout>
            </ScrollView>
    
            <Button
                android:id="@+id/btn_emailUs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:background="@drawable/round_buttons"
                android:text="Email us"></Button>
    
            <Button
                android:id="@+id/btn_callUs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:background="@drawable/round_buttons_green"
                android:text="Call Us"></Button>
        </LinearLayout>
    
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context="com.example.tiagosilva.amob_android.ContactUsFragment"
    android:background="@color/AMOB_gray">
    
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:padding="20dp"
        android:weightSum="3">
    
        <TextView
            android:id="@+id/textView2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="serif"
            android:text="AMOB Headquarters"
            android:textAppearance="@style/TextAppearance.AppCompat"
            android:textColor="@android:color/white"
            android:textStyle="bold" />
    
        <TextView
            android:id="@+id/textView3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="serif"
            android:text="Rua Padre Domingos Joaquim Pereira,1249"
            android:textAppearance="@style/TextAppearance.AppCompat"
            android:textColor="@android:color/white" />
    
        <TextView
            android:id="@+id/textView4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="serif"
            android:text="4760-563 Louro"
            android:textAppearance="@style/TextAppearance.AppCompat"
            android:textColor="@android:color/white"
            android:background="@color/AMOB_gray"/>
    
        <TextView
            android:id="@+id/textView5"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="serif"
            android:text="Vila Nova de Famalicão, Portugal"
            android:textAppearance="@style/TextAppearance.AppCompat"
            android:textColor="@android:color/white" />
    
        <TextView
            android:id="@+id/textView7"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="serif"
            android:text="Phone: (+351) 252 330 900"
            android:textAppearance="@style/TextAppearance.AppCompat"
            android:textColor="@android:color/white" />
    
        <TextView
            android:id="@+id/textView8"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="serif"
            android:text="Fax: (+351) 252 376 887"
            android:textAppearance="@style/TextAppearance.AppCompat"
            android:textColor="@android:color/white" />
    
        <TextView
            android:id="@+id/textView9"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="serif"
            android:text="E-mail: comercial@amob.pt"
            android:textAppearance="@style/TextAppearance.AppCompat"
            android:textColor="@android:color/white" />
    
        <TextView
            android:id="@+id/textView6"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="serif"
            android:text="GPS: 41º 26'.16''N / 8º32'31.89''W"
            android:textAppearance="@style/TextAppearance.AppCompat"
            android:textColor="@android:color/white" />
    
    
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/gps_amob"
            android:id="@+id/gps_map"
            android:layout_weight="3"
            android:layout_marginTop="10dp"
            android:scaleType="fitXY"/>
    
        <Button
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:id="@+id/btn_emailUs"
            android:background="@drawable/round_buttons"
            android:layout_marginTop="10dp"
            android:text="Email us">
        </Button>
    
        <Button
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:id="@+id/btn_callUs"
            android:background="@drawable/round_buttons_green"
            android:layout_marginTop="10dp"
            android:text="Call Us">
        </Button>
    
    </LinearLayout>
    </ScrollView>
    </FrameLayout>