android - 在本地测试和发布时小部件大小不同 - 同一部手机

标签 android widget

我创建了一个小部件,我希望它的大小仅为 80w X 100h。在我的手机上,当我测试未签名的手机时,它工作正常。但是一旦我发布应用程序并在我的手机上测试小部件,它就是 160w x 200h...

我的小部件背景是 80w x 100h。

我的小部件提供程序 xml 文件在下面

<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:updatePeriodMillis="10000"
    android:minWidth="80px"
    android:minHeight="100px"
    android:initialLayout="@layout/widget"/>

My widget.xml layout is

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/widget_base"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:padding="10dip"
  android:orientation="vertical"
  android:background="@drawable/widget_background">
  <TextView
    android:id="@+id/widget_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Take Snap"
    android:textColor="#000000"
    android:layout_alignParentTop="true"
    android:layout_centerInParent="true"/>
  <ImageButton
    android:id="@+id/widget_snap"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:layout_below="@id/widget_text"
    android:background="@xml/widget_button_state"
    />
    </RelativeLayout>

最佳答案

我认为你应该使用 dp 而不是 px(使用 px 很少是个好主意):

android:minWidth="80dp"
android:minHeight="100dp"

关于android - 在本地测试和发布时小部件大小不同 - 同一部手机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5134677/

相关文章:

android - 在哪里存储 JWT token ?

android - 底部导航样式

android - FAB 没有动画 - 附上测试代码和截图

java - Android Firebase 使用地理定位来过滤数据

gwt - 将小部件放置在 gwt 的列表框/下拉列表中

html - 将 iframe 与 <p> 对齐

javascript - 是否可以将动态 React 组件嵌入到单独的 html 文件中,而无需下载文件或使用服务器?

java - 在 Android 3.1 上通过 USB 端口读取和写入数据

javascript - 小部件 - 做什么和不做什么

python - tkinter 列表框用 python 拖放