【发布时间】:2014-02-02 19:42:01
【问题描述】:
我有一个简单的垂直布局,下面有一个 editText 和一个 ImageView。
问题是当用户编辑 EditText 并且它变得太长时,它下面的 ImageView 最终会被“压碎”并调整大小以避免屏幕滚动,如下所示:
当我想要相反的时候,保持图像大小并在溢出时允许屏幕滚动。
通过网上搜索,我以为我必须更改scaleType和adjustViewBounds参数,但我没有运气。
奇怪的是,即使手动设置高 minHeight 似乎也无法解决问题。
有什么建议吗?
编辑:xml 添加:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_gravity="left|center_vertical"
android:hint="Nothing here. Type your thoughts?"
android:background="?attr/background_card"
android:layout_margin="8dp"
android:padding="16dp"/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/imageView" android:layout_gravity="center_horizontal" android:paddingLeft="14dp"
android:paddingRight="14dp"
android:scaleType="center"
android:adjustViewBounds="false"/>
</LinearLayout>
【问题讨论】:
-
你能分享你的布局xml文件吗?
-
当然,刚刚编辑了操作
标签: java android xml imageview