Java Android滚动视图图标

Java Android滚动视图图标,java,android,xml,Java,Android,Xml,我正在开发一个应用程序使用滚动视图,但我有问题。当我滚动到顶部时,第一个按钮不完全可见。这是我的xml和应用程序中的图像。我尝试了不同的方法来修复它,但不可能://(在图像中,您可以看到第一个按钮不可见,只有部分按钮可见) 此代码适用于我: 从LinearLayout <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk

我正在开发一个应用程序使用滚动视图,但我有问题。当我滚动到顶部时,第一个按钮不完全可见。这是我的xml和应用程序中的图像。我尝试了不同的方法来修复它,但不可能://(在图像中,您可以看到第一个按钮不可见,只有部分按钮可见)


此代码适用于我: 从
LinearLayout

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

    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="100dp"
        android:layout_height="280dp"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true">

        <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <Button
                android:id="@+id/button1"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:background="@mipmap/angle" />
            <Button
                android:id="@+id/button2"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:background="@mipmap/currency" />
            <Button
                android:id="@+id/button3"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:layout_centerInParent="true"
                android:background="@mipmap/area" />
            <Button
                android:id="@+id/datasize"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:background="@mipmap/datasize" />
        </LinearLayout>

    </ScrollView>

</RelativeLayout>


增加发动机的高度scrollview@Shahzeb我将添加更多按钮,我只是想对高度设置一些限制,以避免将按钮与背景图像合并://我明白了。尝试在固定高度的布局中移动ScrollView,然后将ScrollView的高度和宽度设置为与父视图匹配。完全不清楚您的屏幕截图用于告知您的情况…尝试删除线性布局上的android:layout\u gravity=“center”,只需删除最后一个按钮,但是我认为您应该强烈地考虑对整个UI采用不同的方法
    <?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="@mipmap/background">

    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="100dp"
        android:layout_height="280dp"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true">

        <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <Button
                android:id="@+id/button1"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:background="@mipmap/angle" />
            <Button
                android:id="@+id/button2"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:background="@mipmap/currency" />
            <Button
                android:id="@+id/button3"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:layout_centerInParent="true"
                android:background="@mipmap/area" />
            <Button
                android:id="@+id/datasize"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:background="@mipmap/datasize" />
        </LinearLayout>

    </ScrollView>

</RelativeLayout>