[英]ScrollView not Working - Relative Layout
I am trying to wrap a realtive view in a scrollview as per the code below. 我试图按照下面的代码在滚动视图中包装一个现实的看法。 However the problem is that the view doesn't scroll, even though part of the view is off the screen. 但是,问题在于即使部分视图不在屏幕上,该视图也不会滚动。 I am testing this on the emulator. 我正在模拟器上对此进行测试。
<?xml version="1.0" encoding="UTF-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"
android:orientation="vertical"
>
<TextView
android:id="@+id/namedetail"
android:background="@drawable/backgroundstate"
android:layout_width="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:layout_height="50dip"
android:textColor="#FF000000"
android:textStyle="bold"
android:textSize="15sp"
android:typeface="sans"
/>
<ImageView android:id="@+id/picturedetail"
android:layout_width="175dip"
android:layout_height="175dip"
android:layout_below="@id/namedetail"
android:layout_marginLeft="75dip"
android:layout_marginTop="10dip"
/>
<ImageView android:id="@+id/infoboxdetail"
android:layout_width="225dip"
android:layout_height="100dip"
android:layout_marginLeft="50dip"
android:layout_marginTop="10dip"
android:layout_below="@id/picturedetail"
android:background="@drawable/backgroundstate"
/>
<TextView
android:id="@+id/descriptiondetail"
android:background="@drawable/backgroundstate"
android:layout_width="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:layout_height="50dip"
android:textColor="#FF000000"
android:textStyle="bold"
android:textSize="15sp"
android:typeface="sans"
android:layout_below="@id/infoboxdetail"
android:layout_marginTop ="10dip"
/>
</RelativeLayout>
</ScrollView>
EDIT 编辑
OK solved - user stupidity - the bottom text box was off the screen on my monitor but not in the emulator. 确定解决-用户愚蠢-底部的文本框不在我的显示器的屏幕上,但在模拟器中。 Making it longer makes it now scroll. 延长它使其现在滚动。
您的RelativeLayout
是horizontal
并且您使用ScrollView
,请尝试使用HorizontalScrollView
。
I believe this is because the RelativeLayout
doesn't stretch based on content. 我相信这是因为RelativeLayout
不会根据内容进行拉伸。 The ScrollView
will fill the screen and then the RelativeLayout
will fill the ScrollView
. ScrollView
将填充屏幕,然后RelativeLayout
将填充ScrollView
。 The size of the RelativeLayout
will not change as you put widgets into it. 当您将小部件放入其中时, RelativeLayout
的大小不会改变。
I would try using another type of layout - perhaps a TableLayout
og a combination of nested LinearLayout
. 我会尝试使用另一种布局-也许是TableLayout
或嵌套的LinearLayout
的组合。
Is there any specific reason why you're using the RelativeLayout
? 您使用RelativeLayout
是否有任何特定原因?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.