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. The ScrollView
will fill the screen and then the RelativeLayout
will fill the ScrollView
. The size of the RelativeLayout
will not change as you put widgets into it.
I would try using another type of layout - perhaps a TableLayout
og a combination of nested LinearLayout
.
Is there any specific reason why you're using the RelativeLayout
?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.