【问题标题】:App Widget always wrapping layout around contentApp Widget 总是围绕内容进行布局
【发布时间】:2013-01-30 05:44:03
【问题描述】:

我已经尝试在布局文件的根元素上将layout_width 属性设置为match_parentfill_parent,用于主屏幕小部件。但是当在 App Widget 中显示时,它仍然被包裹在内容周围。

应用小部件布局:

<StackView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/xxxxxxxxx"
    android:layout_width="match_parent" <!-- always acts like wrap_content -->
    android:layout_height="fill_parent"
    android:gravity="center"
    android:loopViews="true" />

小部件被分配了 4X2 的网格大小:

<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
    android:minWidth="250dp"
    android:minHeight="110dp"
    . . . . .  />

但是在添加到主屏幕后,小部件的宽度在主屏幕上不会占用 4 个网格,它只是围绕内容。如何解决?

【问题讨论】:

    标签: android android-layout android-widget


    【解决方案1】:

    有一个类似的问题,它似乎 minHeight 和 minWidth 因素也是最大尺寸,我敢打赌,如果你将 minWidth 增加到 (4 * 74) - 2 = 294dp 它会起作用。对于您的 minHeight,每个指南的像素高度将为 (2 * 74) - 2 = 146dp,您知道。

    【讨论】:

      猜你喜欢
      • 2017-06-10
      • 1970-01-01
      • 1970-01-01
      • 2019-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-12
      相关资源
      最近更新 更多