[英]android image and button inside a scrollview
I am using following configuration to properly fit image inside a scrollview. 我正在使用以下配置来正确地适应滚动视图内的图像。
<?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:scrollbars="vertical" >
<ImageView
android:id="@+id/textNimbo"
android:layout_width="match_parent"
android:layout_height="2492dp"
android:layout_alignParentRight="true"
android:src="@drawable/inicio"
android:adjustViewBounds="true" />
</ScrollView>
However I need to set also a button inside scrollView and below the ImageView. 但是我需要在scrollView内部和ImageView下面设置一个按钮。 I tried relative and linear layouts inside scrollView but no succes, button is not visible or image doesn't fit to scrollView. 我在scrollView中尝试了相对和线性布局但没有成功,按钮不可见或图像不适合scrollView。 Any recommended configuration? 任何推荐的配置? Thank you. 谢谢。
A ScrollView can only have one direct child element. ScrollView只能有一个直接的子元素。 So to add a Button and an ImageView, you'll need something like this: 所以要添加一个Button和一个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:scrollbars="vertical" >
<LinearLayout
android:id="@+id/layout"
android:layout_width="fill_parent"
android"layout_height="fill_parent">
<ImageView
android:id="@+id/textNimbo"
android:layout_width="match_parent"
android:layout_height="2492dp"
android:layout_alignParentRight="true"
android:src="@drawable/inicio"
android:adjustViewBounds="true" />
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</ScrollView>
您也可以使用ImageButton
I而不是带有透明Button
的ImageView
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.