我试图将imageview放在android studio的滚动视图中,但它不允许我在滚动视图中拖放imageview。
这是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ccc"
android:gravity="center"
android:orientation="vertical"
android:paddingTop="30dp">
<LinearLayout
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#ffffff"
android:gravity="center"
android:orientation="vertical"
android:textColor="#ffffff">
<TextView
android:id="@+id/homepagetxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:textColor="#000000"
android:textStyle="italic" />
</LinearLayout>
</ScrollView>
我可以把它放在线性布局,但它打乱了我的屏幕布局。然而,我不能把它放在滚动视图中,就像在linearlayout结束标记之后一样。
将图像视图置于滚动视图中有任何限制吗?
我非常感谢你的友好回复。
ScrollView只能有一个直接子级。如果要在其中放置多个视图,则必须将这些视图放置在LinearLayout或RelativeLayout中。
滚动视图只能承载一个直接子
将图像视图置于滚动视图中有任何限制吗?
没有。但是,一个ScrollView
只能有一个子级。目前,这是您的LinearLayout
。