ScrollView中的按钮在编码期间未显示

时间:2016-09-08 17:08:07

标签: android

I have a relative Layout inside a scroll view. I am adding text views as you can see in the picture. Now the problem is when the space is full and I am adding the button at the bottom, it is not showing properly. How can I see the button and the other content at the bottom ?

我在滚动视图中有一个相对布局。我正在添加文本视图,如图所示。现在问题是当空间已满并且我在底部添加按钮时,它显示不正确。如何在底部看到按钮和其他内容?这是我图片的xml文件。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="#436dbf"
tools:context="com.kamranchaudhary.pucitportal.Aggreagte">

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentStart="true"
    android:layout_alignParentEnd="true"
    android:layout_alignParentTop="true"
    android:scrollbarStyle="insideOverlay"
    android:scrollbarThumbVertical="@drawable/custom_bar"
    android:layout_alignParentBottom="true">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Pucit Aggregate Calculator"
        android:id="@+id/textView5"
        android:textStyle="bold"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:textColor="#ffffff" />
    <View
        android:layout_width="300dp"
        android:layout_height="1dip"
        android:background="#ffffff"
        android:layout_below="@+id/textView5"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="5dp"
        android:id="@+id/view" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Matric"
        android:id="@+id/textView6"
        android:layout_below="@+id/view"
        android:layout_alignParentStart="true"
        android:textColor="#ffffff"
        android:layout_marginTop="10dp"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Obtained Marks"
        android:id="@+id/textView7"
        android:textColor="#ffffff"
        android:layout_below="@+id/textView6"
        android:layout_alignStart="@+id/view"
        android:layout_marginTop="10dp"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Total Marks"
        android:id="@+id/textView8"
        android:layout_below="@+id/textView7"
        android:layout_alignStart="@+id/textView7"
        android:textColor="#ffffff"
        android:layout_marginTop="10dp" />
    <View
        android:layout_width="300dp"
        android:layout_height="1dip"
        android:background="#ffffff"
        android:id="@+id/view2"
        android:layout_below="@+id/textView8"
        android:layout_alignStart="@+id/textView8"
        android:layout_marginTop="10dp"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Intermediate"
        android:id="@+id/textView9"
        android:layout_below="@+id/view2"
        android:layout_alignParentStart="true"
        android:textColor="#ffffff"
        android:layout_marginTop="10dp"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Obtained Marks"
        android:id="@+id/textView10"
        android:layout_below="@+id/textView9"
        android:layout_alignStart="@+id/view2"
        android:textColor="#ffffff"
        android:layout_marginTop="10dp"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Total Marks"
        android:id="@+id/textView11"
        android:textColor="#ffffff"
        android:layout_below="@+id/textView10"
        android:layout_alignStart="@+id/textView10"
        android:layout_marginTop="10dp"/>
    <View
        android:layout_width="300dp"
        android:layout_height="1dip"
        android:background="#ffffff"
        android:id="@+id/view3"
        android:layout_below="@+id/textView11"
        android:layout_alignStart="@+id/textView11"
        android:layout_marginTop="10dp"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="PUCIT Entry Test"
        android:id="@+id/textView12"
        android:layout_below="@+id/view3"
        android:layout_alignParentStart="true"
        android:textColor="#ffffff"
        android:layout_marginTop="10dp"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Obtained Marks"
        android:id="@+id/textView13"
        android:layout_below="@+id/textView12"
        android:layout_alignStart="@+id/view3"
        android:textColor="#ffffff"
        android:layout_marginTop="10dp"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Total Marks"
        android:id="@+id/textView14"
        android:layout_below="@+id/textView13"
        android:layout_alignStart="@+id/textView13"
        android:textColor="#ffffff"
        android:layout_marginTop="10dp"/>
    <View
        android:layout_width="300dp"
        android:layout_height="1dip"
        android:background="#ffffff"
        android:layout_below="@+id/textView14"
        android:layout_alignStart="@+id/textView14"
        android:layout_marginTop="10dp"
        android:id="@+id/view4" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Extras"
        android:id="@+id/textView15"
        android:layout_below="@+id/view4"
        android:layout_alignParentStart="true"
        android:textColor="#ffffff"
        android:layout_marginTop="10dp"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Are You Hafiz e Quran ?"
        android:id="@+id/textView16"
        android:layout_below="@+id/textView15"
        android:layout_alignStart="@+id/view4"
        android:textColor="#ffffff"
        android:layout_marginTop="10dp"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Intermediate passing Year"
        android:id="@+id/textView17"
        android:layout_below="@+id/textView16"
        android:layout_alignStart="@+id/textView16"
        android:textColor="#ffffff"
        android:layout_marginTop="10dp"/>

    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/checkBox"
        android:checked="false"
        android:layout_alignTop="@+id/textView16"
        android:layout_alignEnd="@+id/textView5" />

    <Spinner
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/spinner"
        android:layout_below="@+id/textView16"
        android:layout_alignParentEnd="true"
        android:layout_marginTop="13dp"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Button"
        android:id="@+id/button4"
        android:layout_below="@+id/textView17"
        android:layout_centerHorizontal="true" />


</RelativeLayout>

</ScrollView>

1 个答案:

答案 0 :(得分:1)

您好像没有正确使用ScrollView

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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"
android:scrollbarStyle="insideOverlay"
android:scrollbarThumbVertical="@drawable/custom_bar"
tools:context="com.kamranchaudhary.pucitportal.Aggreagte">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Pucit Aggregate Calculator"
    android:id="@+id/textView5"
    android:textStyle="bold"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:textColor="#ffffff" />
<View
    android:layout_width="300dp"
    android:layout_height="1dip"
    android:background="#ffffff"
    android:layout_below="@+id/textView5"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="5dp"
    android:id="@+id/view" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Matric"
    android:id="@+id/textView6"
    android:layout_below="@+id/view"
    android:layout_alignParentStart="true"
    android:textColor="#ffffff"
    android:layout_marginTop="10dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Obtained Marks"
    android:id="@+id/textView7"
    android:textColor="#ffffff"
    android:layout_below="@+id/textView6"
    android:layout_alignStart="@+id/view"
    android:layout_marginTop="10dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Total Marks"
    android:id="@+id/textView8"
    android:layout_below="@+id/textView7"
    android:layout_alignStart="@+id/textView7"
    android:textColor="#ffffff"
    android:layout_marginTop="10dp" />
<View
    android:layout_width="300dp"
    android:layout_height="1dip"
    android:background="#ffffff"
    android:id="@+id/view2"
    android:layout_below="@+id/textView8"
    android:layout_alignStart="@+id/textView8"
    android:layout_marginTop="10dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Intermediate"
    android:id="@+id/textView9"
    android:layout_below="@+id/view2"
    android:layout_alignParentStart="true"
    android:textColor="#ffffff"
    android:layout_marginTop="10dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Obtained Marks"
    android:id="@+id/textView10"
    android:layout_below="@+id/textView9"
    android:layout_alignStart="@+id/view2"
    android:textColor="#ffffff"
    android:layout_marginTop="10dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Total Marks"
    android:id="@+id/textView11"
    android:textColor="#ffffff"
    android:layout_below="@+id/textView10"
    android:layout_alignStart="@+id/textView10"
    android:layout_marginTop="10dp"/>
<View
    android:layout_width="300dp"
    android:layout_height="1dip"
    android:background="#ffffff"
    android:id="@+id/view3"
    android:layout_below="@+id/textView11"
    android:layout_alignStart="@+id/textView11"
    android:layout_marginTop="10dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="PUCIT Entry Test"
    android:id="@+id/textView12"
    android:layout_below="@+id/view3"
    android:layout_alignParentStart="true"
    android:textColor="#ffffff"
    android:layout_marginTop="10dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Obtained Marks"
    android:id="@+id/textView13"
    android:layout_below="@+id/textView12"
    android:layout_alignStart="@+id/view3"
    android:textColor="#ffffff"
    android:layout_marginTop="10dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Total Marks"
    android:id="@+id/textView14"
    android:layout_below="@+id/textView13"
    android:layout_alignStart="@+id/textView13"
    android:textColor="#ffffff"
    android:layout_marginTop="10dp"/>
<View
    android:layout_width="300dp"
    android:layout_height="1dip"
    android:background="#ffffff"
    android:layout_below="@+id/textView14"
    android:layout_alignStart="@+id/textView14"
    android:layout_marginTop="10dp"
    android:id="@+id/view4" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Extras"
    android:id="@+id/textView15"
    android:layout_below="@+id/view4"
    android:layout_alignParentStart="true"
    android:textColor="#ffffff"
    android:layout_marginTop="10dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Are You Hafiz e Quran ?"
    android:id="@+id/textView16"
    android:layout_below="@+id/textView15"
    android:layout_alignStart="@+id/view4"
    android:textColor="#ffffff"
    android:layout_marginTop="10dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Intermediate passing Year"
    android:id="@+id/textView17"
    android:layout_below="@+id/textView16"
    android:layout_alignStart="@+id/textView16"
    android:textColor="#ffffff"
    android:layout_marginTop="10dp"/>

<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/checkBox"
    android:checked="false"
    android:layout_alignTop="@+id/textView16"
    android:layout_alignEnd="@+id/textView5" />

<Spinner
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/spinner"
    android:layout_below="@+id/textView16"
    android:layout_alignParentEnd="true"
    android:layout_marginTop="13dp"/>

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Button"
    android:id="@+id/button4"
    android:layout_below="@+id/textView17"
    android:layout_centerHorizontal="true" />

</RelativeLayout>

</ScrollView>

或尝试关闭Parent RelativeLayout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="#436dbf"
tools:context="com.kamranchaudhary.pucitportal.Aggreagte">

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:scrollbarStyle="insideOverlay"
android:scrollbarThumbVertical="@drawable/custom_bar"
android:layout_alignParentBottom="true">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Pucit Aggregate Calculator"
    android:id="@+id/textView5"
    android:textStyle="bold"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:textColor="#ffffff" />
<View
    android:layout_width="300dp"
    android:layout_height="1dip"
    android:background="#ffffff"
    android:layout_below="@+id/textView5"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="5dp"
    android:id="@+id/view" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Matric"
    android:id="@+id/textView6"
    android:layout_below="@+id/view"
    android:layout_alignParentStart="true"
    android:textColor="#ffffff"
    android:layout_marginTop="10dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Obtained Marks"
    android:id="@+id/textView7"
    android:textColor="#ffffff"
    android:layout_below="@+id/textView6"
    android:layout_alignStart="@+id/view"
    android:layout_marginTop="10dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Total Marks"
    android:id="@+id/textView8"
    android:layout_below="@+id/textView7"
    android:layout_alignStart="@+id/textView7"
    android:textColor="#ffffff"
    android:layout_marginTop="10dp" />
<View
    android:layout_width="300dp"
    android:layout_height="1dip"
    android:background="#ffffff"
    android:id="@+id/view2"
    android:layout_below="@+id/textView8"
    android:layout_alignStart="@+id/textView8"
    android:layout_marginTop="10dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Intermediate"
    android:id="@+id/textView9"
    android:layout_below="@+id/view2"
    android:layout_alignParentStart="true"
    android:textColor="#ffffff"
    android:layout_marginTop="10dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Obtained Marks"
    android:id="@+id/textView10"
    android:layout_below="@+id/textView9"
    android:layout_alignStart="@+id/view2"
    android:textColor="#ffffff"
    android:layout_marginTop="10dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Total Marks"
    android:id="@+id/textView11"
    android:textColor="#ffffff"
    android:layout_below="@+id/textView10"
    android:layout_alignStart="@+id/textView10"
    android:layout_marginTop="10dp"/>
<View
    android:layout_width="300dp"
    android:layout_height="1dip"
    android:background="#ffffff"
    android:id="@+id/view3"
    android:layout_below="@+id/textView11"
    android:layout_alignStart="@+id/textView11"
    android:layout_marginTop="10dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="PUCIT Entry Test"
    android:id="@+id/textView12"
    android:layout_below="@+id/view3"
    android:layout_alignParentStart="true"
    android:textColor="#ffffff"
    android:layout_marginTop="10dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Obtained Marks"
    android:id="@+id/textView13"
    android:layout_below="@+id/textView12"
    android:layout_alignStart="@+id/view3"
    android:textColor="#ffffff"
    android:layout_marginTop="10dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Total Marks"
    android:id="@+id/textView14"
    android:layout_below="@+id/textView13"
    android:layout_alignStart="@+id/textView13"
    android:textColor="#ffffff"
    android:layout_marginTop="10dp"/>
<View
    android:layout_width="300dp"
    android:layout_height="1dip"
    android:background="#ffffff"
    android:layout_below="@+id/textView14"
    android:layout_alignStart="@+id/textView14"
    android:layout_marginTop="10dp"
    android:id="@+id/view4" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Extras"
    android:id="@+id/textView15"
    android:layout_below="@+id/view4"
    android:layout_alignParentStart="true"
    android:textColor="#ffffff"
    android:layout_marginTop="10dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Are You Hafiz e Quran ?"
    android:id="@+id/textView16"
    android:layout_below="@+id/textView15"
    android:layout_alignStart="@+id/view4"
    android:textColor="#ffffff"
    android:layout_marginTop="10dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Intermediate passing Year"
    android:id="@+id/textView17"
    android:layout_below="@+id/textView16"
    android:layout_alignStart="@+id/textView16"
    android:textColor="#ffffff"
    android:layout_marginTop="10dp"/>

<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/checkBox"
    android:checked="false"
    android:layout_alignTop="@+id/textView16"
    android:layout_alignEnd="@+id/textView5" />

<Spinner
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/spinner"
    android:layout_below="@+id/textView16"
    android:layout_alignParentEnd="true"
    android:layout_marginTop="13dp"/>

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Button"
    android:id="@+id/button4"
    android:layout_below="@+id/textView17"
    android:layout_centerHorizontal="true" />


</RelativeLayout>

</ScrollView>

</RelativeLayout>