【发布时间】:2013-02-16 22:43:00
【问题描述】:
我有一个带有自定义 ImageView 和两个 TextEdits 的布局;一上一下。为了使它适合多个屏幕,我用 ScrollView 包围了整个东西。
但是,当添加 ScrollView 时,顶部 TextEdit 和 ImageView 以及 ImageView 和底部 TextEdit 之间会出现巨大的间隙(大约屏幕高度)。
我只是覆盖了 ImageView 中的 onDraw() 方法(并且仍在从那里调用 super.onDraw())
这是我的布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="@+id/top_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="@string/top_hint" >
<requestFocus />
</EditText>
<com.javanut13.gememerator.MImageView
android:id="@+id/image_viewer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="0dp"
android:src="@drawable/ic_action_search" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="@+id/bottom_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:layout_weight="3"
android:hint="@string/bottom_hint" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/button_text" />
</LinearLayout>
</LinearLayout>
【问题讨论】:
-
能发个截图吗?我建议启动
hierarchyViewer,这可能会提示您哪个视图占用了这么大的空间。
标签: android android-layout scrollview