Android系统。 ScrollView显示在先前布局的下方

时间:2015-05-20 08:33:07

标签: android android-layout

我的布局中有两个线性布局和ScrollView。 我以编程方式向ScrollView添加了一些视图。 如果ScrollView中的视图位于屏幕内,则一切正常。 但是如果在ScrollView中有更多的视图,那就是scrollview的第一个视图 在布局2下,部分不可见。 我尝试了相对布局。但性能相同。 当然,我希望看到scrollview的顶部元素而不截断。

enter image description here

我的XML如下:

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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/layout1"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:background="@color/backNormal"
              android:orientation="horizontal"
        >
    <ImageView
            android:id="@+id/imageDriverWaitingBack"
            android:layout_width="36dp"
            android:layout_height="36dp"
            android:layout_weight="1"
            android:src="@drawable/back"
            android:gravity="left"
            />

    <TextView
            android:id="@+id/textDriverWaitingTitle"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="Title"
            android:gravity="center"
            android:textColor="@color/text1"
            android:layout_weight="2.13"
            />

    <ImageView
            android:layout_width="36dp"
            android:layout_height="36dp"
            android:gravity="right"
            android:layout_weight="1"
            />
</LinearLayout>
<View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@color/backDark2"
        />

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/layout2"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:background="@color/backNormal"
              android:orientation="horizontal"
        >
    <Button
            android:id="@+id/dButtonWaitMinus"
            android:text='-'
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            style="@style/button_style_normal"
            android:layout_weight="1"
            />

    <TextView
            android:id="@+id/dTextWaitDist"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:text="Distance"
            android:gravity="center"
            android:textColor="@color/text1"
            android:layout_weight="9"
            />

    <Button
            android:id="@+id/dButtonWaitPlus"
            android:text='+'
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_weight="1"
            style="@style/button_style_normal"
            />

</LinearLayout>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"

        >

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  android:id="@+id/driverWaitList"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:background="@color/backNormal"
                  android:orientation="vertical"
                 android:layout_gravity="center_horizontal|center_vertical"
            >
    </LinearLayout>
</ScrollView>
  </LinearLayout>

请有任何想法!谢谢!

0 个答案:

没有答案