【问题标题】:android widget 4x2 full size photo prepare?android 小部件 4x2 全尺寸照片准备好了吗?
【发布时间】:2015-01-01 18:59:10
【问题描述】:

我想设计大约 4x2 单元格大小的小部件。

但是我看了官方文档,

AppWidgetProviderInfo 元数据中有 minWidget 和 minHeight 分别设置。

现在我想在 4x2 单元格中设置全尺寸照片(不使用 9 补丁方法)。

如何以像素为单位准备照片大小并在小部件布局中设置宽度和高度(dp)?

我在文档中看到 minWidth 和 minHeight 4x2 是 250x110dp。

(http://developer.android.com/guide/practices/ui_guidelines/widget_design.html)

我在元数据(AppWidgetProviderInfo)中设置了值,如果我在 widget_layout 中设置大小,则在构建中 手机。小部件显示非常小。

请问如何在不同文件夹中准备 4x2 全尺寸单元格中的照片像素?

非常感谢。

我的英语不好。所以我很难表达我的意思。 (我懂中文)

谢谢。

【问题讨论】:

    标签: android widget


    【解决方案1】:

    如果您希望图像为全​​尺寸,则需要在XML 中指定。在XML 中,您可以指定高度和宽度。然后你可以说adjustViewBounds 并将其设置为“true”。接下来,您可以告诉图像您希望它如何定位。对于我自己,我更喜欢将scaleType 设置为“centerCrop”。

    <ImageView
        android:id="@+id/picture"
        android:layout_width="250dp"
        android:layout_height="110dp"
        android:adjustViewBounds="true"
        android:contentDescription="@string/text"
        android:scaleType="centerCrop"
        android:src="@drawable/a_picture" />
    

    无论哪种方式,您都可以使用 XML 设置来调整图像以适应您的喜好,这只是一个让您入门的示例

    如果您只做小部件,建议使用 9 补丁,但您可以简单地将图像放在可绘制的 hdpi、mdpi、xhdpi 和 xxhdpi 文件夹中。你可以找到缩放比例at this link

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-20
      • 1970-01-01
      • 2020-02-22
      • 1970-01-01
      相关资源
      最近更新 更多