相关疑难解决方法(0)

软件键盘在Android上调整背景图像的大小

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

如你所见,背景有点挤压.任何人都可以了解为什么背景调整大小?

我的布局如下:

<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)

android view android-linearlayout

127
推荐指数
8
解决办法
6万
查看次数

ImageView缩放TOP_CROP

我有一个ImageView显示png的宽高比比设备更大(垂直方向 - 意味着它更长).我希望在保持宽高比,匹配父级宽度以及将图像视图固定到屏幕顶部的同时显示它.

使用CENTER_CROP缩放类型时遇到的问题是,它(可理解)使缩放图像居中,而不是将顶边与图像视图的顶边对齐.

问题FIT_START是图像将适合屏幕高度而不是填充宽度.

我已经通过使用自定义ImageView解决了这个问题,onDraw(Canvas)并使用画布手动覆盖和处理此问题; 这种方法的问题是1)我担心可能有一个更简单的解决方案,2)super(AttributeSet)当在堆有3 mb空闲时尝试设置src img为330kb时,我在调用构造函数时遇到VM mem异常(堆大小为6 mb)并且无法解决原因.

任何想法/建议/解决方案都非常欢迎:)

谢谢

ps我认为解决方案可能是使用矩阵比例类型并自己做,但这似乎与我当前的解决方案相同或更多的工作!

android imageview

84
推荐指数
8
解决办法
4万
查看次数

标签 统计

android ×2

android-linearlayout ×1

imageview ×1

view ×1