[英]App Widget always wrapping layout around content
對於主屏幕小部件,我已經嘗試將layout_width
屬性設置為match_parent
以及布局文件的根元素上的fill_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個網格,而只是圍繞內容。 如何解決呢?
有一個類似的問題,minHeight和minWidth因子也會出現在最大大小中,我敢打賭,如果您將minWidth增加到(4 * 74)-2 = 294dp,它將起作用。 對於您的minHeight,每個參考線的像素高度為(2 * 74)-2 = 146dp,這就是您所知道的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.