我遇到了一个我想要制作的固定尺寸scrollview
的问题。我已经在StackOverflow和其他网站上阅读了许多类似(但不相同)的问题,但没有一个答案对我有帮助,所以我决定问自己的问题。
基本上,我想要一个固定大小scrollview
,里面有不同的控件。基本的一个是textview
内部动态变化的大小。当我更改textview
的文本并且它大于scrollview
时,滚动条会快速闪烁,表示我可以滚动,但无论我刷了多少次手指,它不滚动。然后我尝试用两个或三个手指轻扫,有时(仅计数次数)滚动。
我尝试了很多不同的方法,例如将textview
更改为edittext
,其中focusable = false,因此它不会让用户有机会编辑文本;或者将textview单独放在scrollview中,或者将它包装在linearlayouts,相对布局等中,它仍然不会滚动。
以下是今天的代码。这个滚动视图位于垂直线性布局内,还有其他控件,我不会因为长度而导致,但是如果有人需要它,我会把它放进去。如果有人可以指出我的问题或帮助我解决这个问题,我将非常感激。
XML:
<ScrollView
android:id="@+id/scrollFifthHorizontalLineDetails"
android:layout_width="304dp"
android:layout_height="133dp"
android:layout_gravity="center"
android:layout_marginTop="5dp" >
<LinearLayout
android:id="@+id/rrrr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/txtlblPlaceDetails"
android:layout_width="302dp"
android:layout_height="wrap_content"
android:background="@drawable/placedescriptionbg"
android:text="@string/null_text"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</ScrollView>
我填充TextView的行:
((TextView) findViewById(R.id.txtlblPlaceDetails)).setText(mJsonOb.getString("placeDescription"));
答案 0 :(得分:0)
我在几个月前开发的Android应用程序遇到了类似的问题。我通过增加滚动视图的布局宽度来解决滚动问题。在编辑器中,您实际上可以拖动滚动视图的RHS以超出可见区域。我想我将android:layout_width设置为大约1024。