1

I have this xml layout, but the problem is that, in the scroll view, the height of it is spanning the whole screen and overlapping the bottom linear layout (drawing on top of it). Is there a way so that, I can get the scroll view height going only up to the linear layout on the bottom? I want the bottom 2 buttons to be aligned to the bottom of the screen.

Thanks

<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"
    tools:context=".ActivityProfile" >

    <ScrollView 
         android:id="@+id/scrollView1"
         android:layout_width="match_parent"
         android:layout_height="wrap_content" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >

                <ImageView
                    android:id="@+id/picture_avatar"
                    android:layout_width="90dp" 
                    android:layout_height="310dp"
                    android:background="#bdbdbd"
                    android:src="@drawable/no_avatar" />

                <TextView
                    android:id="@+id/textview_status"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="5dp"
                    android:text="" />

            </LinearLayout>

            <TextView
                android:id="@+id/textview_fullname"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="30sp"
                android:text="" />

            <TextView
                android:id="@+id/textview_email"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:autoLink="email"
                android:text="" />

            <TextView
                android:id="@+id/textview_phone"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:autoLink="phone" 
                android:text="" />

            <TextView
                android:id="@+id/textview_website"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:autoLink="web"
                android:text="" />

            <TextView
                android:id="@+id/textview_bio"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="7dp"
                android:layout_marginBottom="7dp"
                android:text="" />

            <TextView
                android:id="@+id/textview_lastactive"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="" />

            <TextView
                android:id="@+id/textview_datejoined"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="" />

            <TextView
                android:id="@+id/textview_dateleft"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="" />

        </LinearLayout>

    </ScrollView>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/button_logout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="CloseActivity"
            android:text="@+string/back" />

        <Button
            android:id="@+id/button_exit"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:onClick="GoToEditProfile"
            android:text="@+string/edit" />

    </LinearLayout>

</RelativeLayout>
4

2 回答 2

5

将其更改为 LinearLayout 并使用 layout_weight :

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

<ScrollView 
     android:id="@+id/scrollView1"
     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" >


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <ImageView
                android:id="@+id/picture_avatar"
                android:layout_width="90dp" 
                android:layout_height="310dp"
                android:background="#bdbdbd"
                android:src="@drawable/no_avatar" />

            <TextView
                android:id="@+id/textview_status"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:text="" />

        </LinearLayout>

        <TextView
            android:id="@+id/textview_fullname"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="30sp"
            android:text="" />

        <TextView
            android:id="@+id/textview_email"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:autoLink="email"
            android:text="" />

        <TextView
            android:id="@+id/textview_phone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:autoLink="phone" 
            android:text="" />

        <TextView
            android:id="@+id/textview_website"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:autoLink="web"
            android:text="" />

        <TextView
            android:id="@+id/textview_bio"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="7dp"
            android:layout_marginBottom="7dp"
            android:text="" />

        <TextView
            android:id="@+id/textview_lastactive"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="" />

        <TextView
            android:id="@+id/textview_datejoined"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="" />

        <TextView
            android:id="@+id/textview_dateleft"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="" />

    </LinearLayout>

</ScrollView>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/button_logout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="CloseActivity"
        android:text="@+string/back" />

    <Button
        android:id="@+id/button_exit"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:onClick="GoToEditProfile"
        android:text="@+string/edit" />

</LinearLayout>

</LinearLayout>

希望能帮到你。

于 2013-07-17T00:49:26.893 回答
0

在您的线性布局中(在底部)将其添加到位于滚动视图下方

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:orientation="horizontal"
    android:layout_below=""@+id/scrollView1"   <-- this code
>

并将主基础布局更改为线性布局,使其不会重叠

<LinearLayout 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"
tools:context=".ActivityProfile"
android:orientation='horizontal'
>

不要忘记在最后更改选项卡

</LinearLayout>
于 2013-07-17T00:36:47.487 回答