为什么我设置的scrollview没有生效?

dxawmhmy 2011-07-15 11:49:57
下面这段代码是放在一个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,但是在显示内容的时候没有。
到底怎么回事?
...全文
329 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
dxawmhmy 2011-07-16
  • 打赏
  • 举报
回复
完整代码如下:

<?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>
xinqiqi123 2011-07-15
  • 打赏
  • 举报
回复
如果ScrollView中的内容没有超出它的高度范围,Scrollbar是不会显示的也没必要显示
fishmen26 2011-07-15
  • 打赏
  • 举报
回复
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="vertical">

你的ScrollView 默认为要达到屏幕高度才会显示Scrollbar
你可以把android:layout_height="100dip"试试,效果就会出来。
雨松MOMO 2011-07-15
  • 打赏
  • 举报
回复
setContentView(R.layout.main);
楼主这里现实的是你的布局吗??
fishmen26 2011-07-15
  • 打赏
  • 举报
回复
请贴多一点代码出来,还有dispatch_transact_info_text4 里显示的内容是什么
dxawmhmy 2011-07-15
  • 打赏
  • 举报
回复
纠结了 ,都没有,高度达到了,换了layout_height都不行
、我还拿以前做的例子来看,没发现什么。

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧