下面这段代码是放在一个RelativeLayout里面。
<LinearLayout 
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/dispatch_transact_info_text3"
android:layout_alignLeft="@id/dispatch_transact_info_text3"
>
<ScrollView 
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="vertical"

>
<TextView
android:id="@+id/dispatch_transact_info_text4"
android:layout_width="292px"
android:layout_height="312px"
android:background="@drawable/edit_content6"
android:paddingTop="15px"
android:paddingLeft="5px"
android:paddingRight="5px"
android:paddingBottom="5px"
style="@style/tvT3"

/>
</ScrollView>
</LinearLayout>
在系统自带的图形设计页面里,也可以看到有scrollBar,但是在显示内容的时候没有。
到底怎么回事?

解决方案 »

  1.   

    setContentView(R.layout.main);
    楼主这里现实的是你的布局吗??
      

  2.   

    <ScrollView 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scrollbars="vertical">你的ScrollView 默认为要达到屏幕高度才会显示Scrollbar
    你可以把android:layout_height="100dip"试试,效果就会出来。
      

  3.   

    如果ScrollView中的内容没有超出它的高度范围,Scrollbar是不会显示的也没必要显示
      

  4.   

    纠结了 ,都没有,高度达到了,换了layout_height都不行
    、我还拿以前做的例子来看,没发现什么。
      

  5.   

    请贴多一点代码出来,还有dispatch_transact_info_text4 里显示的内容是什么
      

  6.   

    完整代码如下:<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:background="@drawable/bg"
    >

    <include android:id="@+id/zl_headerBar" 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true"
    layout="@layout/topbar" />

    <RelativeLayout 
    android:layout_width="307px"
    android:layout_height="380px"
    android:background="#FFFFFF"
    android:layout_marginTop="7px"
    android:layout_marginLeft="7px"
    android:layout_marginRight="7px"
    android:layout_marginBottom="7px"
    >
    <TextView 
    android:id="@+id/dispatch_transact_info_text1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/file_title"
    android:layout_marginLeft="7px"
    android:layout_marginTop="9px"
    style="@style/tvT2"
    />
    <TextView
    android:id="@+id/dispatch_transact_info_text2"
    android:layout_width="200px"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/dispatch_transact_info_text1"
    android:singleLine="true"
    android:layout_marginLeft="7px"
    android:layout_marginTop="9px"
    android:text=""
    style="@style/tvT2"
    />

    <TextView 
    android:id="@+id/dispatch_transact_info_text3"
    android:layout_width="86px"
    android:layout_height="wrap_content"
    android:text="@string/content"
    android:layout_alignLeft="@id/dispatch_transact_info_text1"
    android:layout_below="@id/dispatch_transact_info_text1"
    android:layout_marginTop="9px"
    android:gravity="center_horizontal"
    style="@style/tvT2"
    />
    <LinearLayout 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/dispatch_transact_info_text3"
    android:layout_alignLeft="@id/dispatch_transact_info_text3"
    >
    <ScrollView 
    android:layout_width="wrap_content"
    android:layout_height="312px"
    android:scrollbars="vertical"

    >
    <TextView
    android:id="@+id/dispatch_transact_info_text4"
    android:layout_width="292px"
    android:layout_height="312px"
    android:background="@drawable/edit_content6"
    android:paddingTop="15px"
    android:paddingLeft="5px"
    android:paddingRight="5px"
    android:paddingBottom="5px"
    style="@style/tvT3"

    />
    </ScrollView>
    </LinearLayout>
    </RelativeLayout>

    <RelativeLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <Button 
    android:id="@+id/dispatch_transact_info_button4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/btn_tab"
    android:text="@string/attachment1"
    android:layout_alignParentBottom="true"
    style="@style/tv_tag"
    />

    <ImageView 
    android:id="@+id/dispatch_transact_info_tag_divider"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/img_divider"
    android:layout_alignParentBottom="true"
    android:layout_toRightOf="@id/dispatch_transact_info_button4"
    />

    <Button 
    android:id="@+id/dispatch_transact_info_button5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/btn_tab"
    android:text="@string/transact_process"
    android:layout_alignParentBottom="true"
    android:layout_toRightOf="@id/dispatch_transact_info_tag_divider"
    style="@style/tv_tag"
    />
    </RelativeLayout>
    </LinearLayout>