内部线性布局不可见

时间:2014-08-19 06:57:29

标签: android android-linearlayout

以下是我的布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#0A4152"
    android:orientation="vertical" >

    <ScrollView
        android:id="@+id/scrollViewRegister"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#0A4152" >

        <RelativeLayout
            android:id="@+id/layoutRegister"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:overScrollMode="never"
            android:paddingBottom="@dimen/activity_vertical_margin"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:paddingTop="@dimen/activity_vertical_margin" >

            <ImageButton
                android:id="@+id/imgBtnPicDoctorDetail"
                android:layout_width="100dip"
                android:layout_height="100dip"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="20dip"
                android:adjustViewBounds="true"
                android:alpha="0.5"
                android:background="@drawable/image_round_corners"
                android:contentDescription="@string/user_image_description"
                android:scaleType="centerCrop"
                android:src="@drawable/doctor" />

            <TextView
                android:id="@+id/txtDoctorName"
                android:layout_width="350dip"
                android:layout_height="40dip"
                android:layout_below="@+id/imgBtnPicDoctorDetail"
                android:layout_marginBottom="20dip"
                android:text="abc"
                android:maxLines="1" />

            <TextView
                android:id="@+id/txtDoctorAddressLine"
                android:layout_width="350dip"
                android:layout_height="100dip"
                android:layout_below="@+id/txtDoctorName"
                android:layout_marginBottom="20dip"
                android:gravity="top"
                android:text="abc"
                android:maxLines="3" />

            <TextView
                android:id="@+id/txtDoctorPhone"
                android:layout_width="350dip"
                android:layout_height="40dip"
                android:layout_below="@+id/txtDoctorAddressLine"
                android:layout_marginBottom="20dip"
                android:text="abc"
                android:maxLines="1" />

            <TextView
                android:id="@+id/txtDoctorEmail"
                android:layout_width="350dip"
                android:layout_height="40dip"
                android:layout_below="@+id/txtDoctorPhone"
                android:layout_marginBottom="20dip"
                android:text="abc"
                android:maxLines="1" />

            <TextView
                android:id="@+id/txtDoctorExperience"
                android:layout_width="wrap_content"
                android:layout_height="40dip"
                android:layout_below="@+id/txtDoctorEmail"
                android:layout_marginBottom="20dip"
                android:paddingTop="10dip"
                android:textColor="#ffffff"
                android:textSize="20sp"
                android:text="abc"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/txtDoctorQualification"
                android:layout_width="100dip"
                android:layout_height="40dip"
                android:layout_below="@+id/txtDoctorExperience"
                android:layout_marginBottom="20dip"
                android:paddingTop="10dip"
                android:textColor="#ffffff"
                android:textSize="20sp"
                android:text="abc"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/txtDoctorDescription"
                android:layout_width="100dip"
                android:layout_height="40dip"
                android:layout_below="@+id/txtDoctorExperience"
                android:layout_marginBottom="20dip"
                android:paddingTop="10dip"
                android:textColor="#ffffff"
                android:textSize="20sp"
                android:text="abc"
                android:textStyle="bold" />
        </RelativeLayout>
    </ScrollView>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#ffffff"
        android:orientation="horizontal" >

      <Button
        android:id="@+id/btnNewAppointment"
        android:layout_width="125dip"
        android:layout_height="40dip"
        android:gravity="center_horizontal"
        android:paddingTop="10dip"
        android:background="#ffffff"
        android:text="@string/new_appointment"
        android:textColor="#0A4152"
        android:textStyle="bold" />

      <Button
        android:id="@+id/btnLocateMe"
        android:layout_width="125dip"
        android:layout_height="40dip"
        android:gravity="center_horizontal"
        android:paddingTop="10dip"
        android:background="#ffffff"
        android:text="@string/locate_me"
        android:textColor="#0A4152"
        android:textStyle="bold" />

    </LinearLayout>
</LinearLayout>  

在运行应用程序时,包含按钮的底部线性布局不可见。只有滚动视图及其控件可见。

2 个答案:

答案 0 :(得分:1)

使用这个。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:background="#0A4152"
 android:orientation="vertical" >

 <ScrollView
    android:id="@+id/scrollViewRegister"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.9"
    android:background="#0A4152" >

    <RelativeLayout
        android:id="@+id/layoutRegister"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:overScrollMode="never"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin" >

        <ImageButton
            android:id="@+id/imgBtnPicDoctorDetail"
            android:layout_width="100dip"
            android:layout_height="100dip"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="20dip"
            android:adjustViewBounds="true"
            android:alpha="0.5"
            android:background="@drawable/image_round_corners"
            android:contentDescription="@string/user_image_description"
            android:scaleType="centerCrop"
            android:src="@drawable/doctor" />

        <TextView
            android:id="@+id/txtDoctorName"
            android:layout_width="350dip"
            android:layout_height="40dip"
            android:layout_below="@+id/imgBtnPicDoctorDetail"
            android:layout_marginBottom="20dip"
            android:maxLines="1"
            android:text="abc" />

        <TextView
            android:id="@+id/txtDoctorAddressLine"
            android:layout_width="350dip"
            android:layout_height="100dip"
            android:layout_below="@+id/txtDoctorName"
            android:layout_marginBottom="20dip"
            android:gravity="top"
            android:maxLines="3"
            android:text="abc" />

        <TextView
            android:id="@+id/txtDoctorPhone"
            android:layout_width="350dip"
            android:layout_height="40dip"
            android:layout_below="@+id/txtDoctorAddressLine"
            android:layout_marginBottom="20dip"
            android:maxLines="1"
            android:text="abc" />

        <TextView
            android:id="@+id/txtDoctorEmail"
            android:layout_width="350dip"
            android:layout_height="40dip"
            android:layout_below="@+id/txtDoctorPhone"
            android:layout_marginBottom="20dip"
            android:maxLines="1"
            android:text="abc" />

        <TextView
            android:id="@+id/txtDoctorExperience"
            android:layout_width="wrap_content"
            android:layout_height="40dip"
            android:layout_below="@+id/txtDoctorEmail"
            android:layout_marginBottom="20dip"
            android:paddingTop="10dip"
            android:text="abc"
            android:textColor="#ffffff"
            android:textSize="20sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txtDoctorQualification"
            android:layout_width="100dip"
            android:layout_height="40dip"
            android:layout_below="@+id/txtDoctorExperience"
            android:layout_marginBottom="20dip"
            android:paddingTop="10dip"
            android:text="abc"
            android:textColor="#ffffff"
            android:textSize="20sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txtDoctorDescription"
            android:layout_width="100dip"
            android:layout_height="40dip"
            android:layout_below="@+id/txtDoctorExperience"
            android:layout_marginBottom="20dip"
            android:paddingTop="10dip"
            android:text="abc"
            android:textColor="#ffffff"
            android:textSize="20sp"
            android:textStyle="bold" />
    </RelativeLayout>
</ScrollView>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="0.1"
    android:background="#ffffff"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/btnNewAppointment"
        android:layout_width="125dip"
        android:layout_height="40dip"
        android:background="#ffffff"
        android:gravity="center_horizontal"
        android:paddingTop="10dip"
        android:text="@string/new_appointment"
        android:textColor="#0A4152"
        android:textStyle="bold" />

    <Button
        android:id="@+id/btnLocateMe"
        android:layout_width="125dip"
        android:layout_height="40dip"
        android:background="#ffffff"
        android:gravity="center_horizontal"
        android:paddingTop="10dip"
        android:text="@string/locate_me"
        android:textColor="#0A4152"
        android:textStyle="bold" />
</LinearLayout>

</LinearLayout>

答案 1 :(得分:0)

我认为你的xml设计很糟糕.scrollView通常在全屏使用你设置它的高度wrap_content所以如果内容很长时间会发生什么?把它改成像这样的东西

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#0A4152"
android:orientation="vertical" >

<ScrollView
    android:id="@+id/scrollViewRegister"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_above="@+id/lin"
    android:background="#0A4152" >

    <RelativeLayout
        android:id="@+id/layoutRegister"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:overScrollMode="never"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin" >

        <ImageButton
            android:id="@+id/imgBtnPicDoctorDetail"
            android:layout_width="100dip"
            android:layout_height="100dip"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="20dip"
            android:adjustViewBounds="true"
            android:alpha="0.5"
            android:background="@drawable/image_round_corners"
            android:contentDescription="@string/user_image_description"
            android:scaleType="centerCrop"
            android:src="@drawable/doctor" />

        <TextView
            android:id="@+id/txtDoctorName"
            android:layout_width="350dip"
            android:layout_height="40dip"
            android:layout_below="@+id/imgBtnPicDoctorDetail"
            android:layout_marginBottom="20dip"
            android:text="abc"
            android:maxLines="1" />

        <TextView
            android:id="@+id/txtDoctorAddressLine"
            android:layout_width="350dip"
            android:layout_height="100dip"
            android:layout_below="@+id/txtDoctorName"
            android:layout_marginBottom="20dip"
            android:gravity="top"
            android:text="abc"
            android:maxLines="3" />

        <TextView
            android:id="@+id/txtDoctorPhone"
            android:layout_width="350dip"
            android:layout_height="40dip"
            android:layout_below="@+id/txtDoctorAddressLine"
            android:layout_marginBottom="20dip"
            android:text="abc"
            android:maxLines="1" />

        <TextView
            android:id="@+id/txtDoctorEmail"
            android:layout_width="350dip"
            android:layout_height="40dip"
            android:layout_below="@+id/txtDoctorPhone"
            android:layout_marginBottom="20dip"
            android:text="abc"
            android:maxLines="1" />

        <TextView
            android:id="@+id/txtDoctorExperience"
            android:layout_width="wrap_content"
            android:layout_height="40dip"
            android:layout_below="@+id/txtDoctorEmail"
            android:layout_marginBottom="20dip"
            android:paddingTop="10dip"
            android:textColor="#ffffff"
            android:textSize="20sp"
            android:text="abc"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txtDoctorQualification"
            android:layout_width="100dip"
            android:layout_height="40dip"
            android:layout_below="@+id/txtDoctorExperience"
            android:layout_marginBottom="20dip"
            android:paddingTop="10dip"
            android:textColor="#ffffff"
            android:textSize="20sp"
            android:text="abc"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txtDoctorDescription"
            android:layout_width="100dip"
            android:layout_height="40dip"
            android:layout_below="@+id/txtDoctorExperience"
            android:layout_marginBottom="20dip"
            android:paddingTop="10dip"
            android:textColor="#ffffff"
            android:textSize="20sp"
            android:text="abc"
            android:textStyle="bold" />
    </RelativeLayout>
</ScrollView>

<LinearLayout
    android:id="@+id/lin"
    android:layout_width="fill_parent"
    android:layout_height="50dp"
    android:background="#ffffff"
    android:layout_alignParentLeft="true"
        android:layout_alignParentBottom="true"
    android:orientation="horizontal" >

  <Button
    android:id="@+id/btnNewAppointment"
    android:layout_width="125dip"
    android:layout_height="40dip"
    android:gravity="center_horizontal"
    android:paddingTop="10dip"
    android:background="#ffffff"
    android:text="@string/new_appointment"
    android:textColor="#0A4152"
    android:textStyle="bold" />

  <Button
    android:id="@+id/btnLocateMe"
    android:layout_width="125dip"
    android:layout_height="40dip"
    android:gravity="center_horizontal"
    android:paddingTop="10dip"
    android:background="#ffffff"
    android:text="@string/locate_me"
    android:textColor="#0A4152"
    android:textStyle="bold" />

</LinearLayout>
</RelativeLayout>