2013-03-28 56 views
1

我有这样的布局内的滚动视图:的Android滚动视图不滚动

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

    <!-- HEADER --> 

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

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="1dp" 
      android:background="#ffffff" 
      android:orientation="vertical" >   
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="1dp" 
      android:background="#868686" 
      android:orientation="vertical" >   
     </LinearLayout> 

     <RelativeLayout 
      android:id="@+id/parent_linear" 
      android:layout_width="fill_parent" 
      android:layout_height="50dp" 
      android:background="@drawable/gradient_header" > 

      <TextView 
       android:id="@+id/textView1" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" 
       android:layout_centerInParent="true" 
       android:layout_centerVertical="true" 
       android:layout_marginBottom="@dimen/margin_normal" 
       android:layout_marginTop="@dimen/margin_small" 
       android:gravity="center_horizontal" 
       android:text="@string/proposed_plan_prompt" 
       android:textColor="#797A77" 
       android:textSize="15sp" 
       android:textStyle="bold" /> 

     </RelativeLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="2dp" 
      android:background="#C7C7C7" 
      android:orientation="vertical" >   
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="3dp" 
      android:background="@drawable/gradient_header_separator" 
      android:orientation="vertical" >   
     </LinearLayout> 

    </LinearLayout> 

    <!-- BODY --> 

    <!-- Proposed plan (summary) --> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="@dimen/margin_normal" 
     android:layout_marginLeft="@dimen/margin_normal" 
     android:layout_marginRight="@dimen/margin_normal" 
     android:background="@drawable/border" 
     android:orientation="horizontal" > 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:layout_marginLeft="@dimen/margin_small" 
      android:layout_marginRight="@dimen/margin_small" 
      android:orientation="vertical" > 

      <TextView 
       android:id="@+id/providerNameView" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="2dp" 
       android:text="ABCD" 
       android:textSize="25sp" 
       android:textStyle="bold" />   

      <TextView 
       android:id="@+id/planView" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="2dp" 
       android:text="1234" 
       android:textSize="12sp" 
       android:textColor="#737373"/> 

     </LinearLayout> 

     <View 
      android:id="@+id/separator" 
      android:layout_width="1dip" 
      android:layout_height="50dp" 
      android:layout_marginTop="@dimen/margin_small" 
      android:background="@drawable/gradient_vertical" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:layout_alignParentRight="true" 
      android:layout_marginLeft="@dimen/margin_small" 
      android:layout_marginRight="@dimen/margin_small" 
      android:orientation="vertical" > 

      <LinearLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_gravity="right" 
       android:layout_marginLeft="@dimen/margin_small" 
       android:layout_marginRight="@dimen/margin_small" 
       android:gravity="top" 
       android:orientation="horizontal" > 

       <TextView 
        android:id="@+id/priceView" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="XY" 
        android:textSize="32sp" 
        android:textStyle="bold" /> 

       <TextView 
        android:id="@+id/textView3" 
        android:layout_width="wrap_content" 
        android:layout_height="match_parent" 
        android:text="+123" 
        android:textColor="#565756" 
        android:textSize="12sp" /> 

      </LinearLayout> 

      <TextView 
       android:id="@+id/totPriceView" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="right" 
       android:text="(information)" 
       android:textColor="#737373" 
       android:textSize="12sp" /> 

     </LinearLayout> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="@dimen/margin_normal" 
     android:layout_marginLeft="@dimen/margin_normal" 
     android:layout_marginRight="@dimen/margin_small" 
     android:layout_marginTop="@dimen/margin_normal" 
     android:orientation="vertical" > 

     <TextView 
      android:id="@+id/detailsTextView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Choose:" 
      android:textSize="12sp" 
      android:textStyle="bold" /> 

     <SeekBar 
      android:id="@+id/seekBar1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" /> 

     <TextView 
      android:id="@+id/detailsTextView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="@dimen/margin_small" 
      android:text="Best" 
      android:textColor="#737373" 
      android:textSize="12sp" /> 
    </LinearLayout> 

    <TextView 
     android:id="@+id/detailsTextView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="@dimen/margin_normal" 
     android:text="Details:" 
     android:textSize="12sp" 
     android:textStyle="bold" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="@dimen/margin_normal" 
     android:layout_marginLeft="@dimen/margin_normal" 
     android:layout_marginRight="@dimen/margin_small" 
     android:layout_marginTop="@dimen/margin_small" 
     android:background="@drawable/border" 
     android:orientation="vertical" > 

     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 

      <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:layout_gravity="right" 
        android:layout_marginLeft="90dp" 
        android:layout_marginRight="@dimen/margin_small" 
        android:background="@drawable/border" 
        android:orientation="vertical" > 

        <RelativeLayout 
         android:id="@+id/line1Layout" 
         android:layout_width="match_parent" 
         android:layout_height="30sp" 
         android:background="#ffffff" 
         android:gravity="center_vertical" 
         android:orientation="horizontal" > 

         <TextView 
          android:id="@+id/line1Title" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:textSize="@dimen/font_normal" /> 

         <TextView 
          android:id="@+id/line1Text" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_alignParentRight="true" 
          android:background="@drawable/border_attribute" 
          android:textSize="@dimen/font_normal" 
          android:visibility="invisible" /> 
        </RelativeLayout> 

        <RelativeLayout 
         android:id="@+id/line2Layout" 
         android:layout_width="match_parent" 
         android:layout_height="30sp" 
         android:background="#EAEAEA" 
         android:gravity="center_vertical" 
         android:orientation="horizontal" > 

         <TextView 
          android:id="@+id/line2Title" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:textSize="@dimen/font_normal" /> 

         <TextView 
          android:id="@+id/line2Text" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_alignParentRight="true" 
          android:background="@drawable/border_attribute" 
          android:textSize="@dimen/font_normal" 
          android:visibility="invisible" /> 
        </RelativeLayout> 

        <RelativeLayout 
         android:id="@+id/line3Layout" 
         android:layout_width="match_parent" 
         android:layout_height="30sp" 
         android:background="#ffffff" 
         android:gravity="center_vertical" 
         android:orientation="horizontal" > 

         <TextView 
          android:id="@+id/line3Title" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:textSize="@dimen/font_normal" /> 

         <TextView 
          android:id="@+id/line3Text" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_alignParentRight="true" 
          android:background="@drawable/border_attribute" 
          android:textSize="@dimen/font_normal" 
          android:visibility="invisible" /> 
        </RelativeLayout> 

        <RelativeLayout 
         android:id="@+id/line4Layout" 
         android:layout_width="match_parent" 
         android:layout_height="30sp" 
         android:background="#EAEAEA" 
         android:gravity="center_vertical" 
         android:orientation="horizontal" > 

         <TextView 
          android:id="@+id/line4Title" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:textSize="@dimen/font_normal" /> 

         <TextView 
          android:id="@+id/line4Text" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_alignParentRight="true" 
          android:background="@drawable/border_attribute" 
          android:textSize="@dimen/font_normal" 
          android:visibility="invisible" /> 
        </RelativeLayout> 

        <RelativeLayout 
         android:id="@+id/line5Layout" 
         android:layout_width="match_parent" 
         android:layout_height="30sp" 
         android:background="#ffffff" 
         android:gravity="center_vertical" 
         android:orientation="horizontal" > 

         <TextView 
          android:id="@+id/line5Title" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:textSize="@dimen/font_normal" /> 

         <TextView 
          android:id="@+id/line5Text" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_alignParentRight="true" 
          android:background="@drawable/border_attribute" 
          android:textSize="@dimen/font_normal" 
          android:visibility="invisible" /> 
        </RelativeLayout> 

        <RelativeLayout 
         android:id="@+id/line6Layout" 
         android:layout_width="match_parent" 
         android:layout_height="30sp" 
         android:background="#EAEAEA" 
         android:gravity="center_vertical" 
         android:orientation="horizontal" > 

         <TextView 
          android:id="@+id/line6Title" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:textSize="@dimen/font_normal" /> 

         <TextView 
          android:id="@+id/line6Text" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_alignParentRight="true" 
          android:background="@drawable/border_attribute" 
          android:textSize="@dimen/font_normal" 
          android:visibility="invisible" /> 
        </RelativeLayout> 
       </LinearLayout> 
      </ScrollView> 

      <ImageView 
       android:id="@+id/imageView1" 
       android:layout_width="100dp" 
       android:layout_height="140dp" 
       android:layout_gravity="left|center_vertical" 
       android:src="@drawable/robin4" /> 
     </FrameLayout> 

     <Button 
      android:id="@+id/button_proposed_extras" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="@dimen/margin_small" 
      android:layout_marginLeft="20dp" 
      android:layout_marginRight="20dp" 
      android:layout_marginTop="@dimen/margin_normal" 
      android:background="@drawable/button_transparent" 
      android:text="@string/extras_title" 
      android:textColor="#298A17" 
      android:textStyle="bold|italic" 
      android:visibility="invisible" /> 
    </LinearLayout> 

     <Button 
     android:id="@+id/button_proposed_change" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="@dimen/margin_normal" 
     android:layout_marginLeft="20dp" 
     android:layout_marginRight="20dp" 
     android:background="@drawable/button" 
     android:text="@string/proposition_change_title" 
     android:textColor="#ffffff" 
     android:textStyle="bold" /> 

    <Button 
     android:id="@+id/button_proposed_no_change" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="@dimen/margin_normal" 
     android:layout_marginLeft="20dp" 
     android:layout_marginRight="20dp" 
     android:background="@drawable/button_silver" 
     android:text="@string/proposition_no_change_title" 
     android:textColor="#298A17" 
     android:textStyle="bold" /> 


</LinearLayout> 
  • 与滚动视图显示在最大尺寸的一部分并且不是滚动。

  • 末这两个按钮没有显示,他们显然不适合在屏幕上。

我想使滚动工作,以便有按钮出现。

为什么滚动布局在最大尺寸的显示被滚动呢?

会是什么解决方案?

+0

我们能否拥有此布局的屏幕截图? – ChristopheCVB

回答

0

如果不滚动,因为它的高度是wrap_content。

+0

我尝试了每个参数的高度,它确实没有改变。 – shuot

+0

尝试设置一个任意100dip的高度只是为了测试... – ChristopheCVB

2

为了使按钮出现在屏幕上,你应该有滚动内的按钮了。大多数情况下,如果屏幕包含许多组件,则设计的屏幕应该具有父视图作为父视图。 Main ScrollView - > LinearLayout/RelativeLayout - >根据需要添加组件。通过这样做,您应该能够看到按钮。在这种方式下,即使您的布局更改为横向,组件也不会隐藏,并且会显示在滚动条中。希望你明白我的观点,它可以帮助你解决你的问题。

就上面的代码而言,由于按钮不在滚动视图中,所以您将无法看到按钮,因此下面的视图被隐藏。

0

由于ChristopheCVB说,你的滚动型需要不被wrap_content。 ScrollView只会滚动,如果它包含的内容较大(读取较高的为垂直ScrollView和较宽为水平ScrollView)ScrollView本身。如果它较小,则不需要滚动。