每当出现软件键盘时,它都会调整背景图像的大小.请参阅下面的屏幕截图:

如你所见,背景有点挤压.任何人都可以了解为什么背景调整大小?
我的布局如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/page_bg"
android:isScrollContainer="false"
>
<LinearLayout android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_width="fill_parent"
>
<EditText android:id="@+id/CatName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="textCapSentences"
android:lines="1"
/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/save"
android:onClick="saveCat"
/>
</LinearLayout>
<ImageButton
android:id="@+id/add_totalk"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="@null"
android:src="@drawable/add_small"
android:scaleType="center"
android:onClick="createToTalk"
android:layout_marginTop="5dp"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我有一个ImageView显示png的宽高比比设备更大(垂直方向 - 意味着它更长).我希望在保持宽高比,匹配父级宽度以及将图像视图固定到屏幕顶部的同时显示它.
使用CENTER_CROP缩放类型时遇到的问题是,它(可理解)使缩放图像居中,而不是将顶边与图像视图的顶边对齐.
问题FIT_START是图像将适合屏幕高度而不是填充宽度.
我已经通过使用自定义ImageView解决了这个问题,onDraw(Canvas)并使用画布手动覆盖和处理此问题; 这种方法的问题是1)我担心可能有一个更简单的解决方案,2)super(AttributeSet)当在堆有3 mb空闲时尝试设置src img为330kb时,我在调用构造函数时遇到VM mem异常(堆大小为6 mb)并且无法解决原因.
任何想法/建议/解决方案都非常欢迎:)
谢谢
ps我认为解决方案可能是使用矩阵比例类型并自己做,但这似乎与我当前的解决方案相同或更多的工作!
假设我正在从API获取一些图像。我不知道该图像的尺寸将是未来的时间,但我知道我要的是形象,成为src一个ImageView我已经设置为某个特定的大小。我希望从API获得的任何图像都可以填满整个图像ImageView,我想保留宽高比,并且不在乎某个尺寸(宽度或高度)对于视图的设置大小是否太大,因此我使用centerCrop。
<ImageView
android:layout_width="400px"
android:layout_height="300px"
android:scaleType="centerCrop" />
Run Code Online (Sandbox Code Playgroud)
如果从API返回的图像是这样的:
当将其设置为ImageView的src时,结果将类似于此(阴影部分被裁剪掉):
但是,我收到一个要求,我们应该始终显示图像的顶部并从下至上进行裁剪。因此,所需的结果是这样的:
我敢肯定这是可能的,但是我是一个网络人,不在这里工作。以ImageView某种方式扩展,还是尝试使用scaleType="matrix"and setImageMatrix(),或者是第三种未提及的选项会更好吗?