[英]android image and button 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>
但是我需要在scrollView內部和ImageView下面設置一個按鈕。 我在scrollView中嘗試了相對和線性布局但沒有成功,按鈕不可見或圖像不適合scrollView。 任何推薦的配置? 謝謝。
ScrollView只能有一個直接的子元素。 所以要添加一個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.