android - 锁屏小部件太小

标签 android android-widget

我在查找 Android 4.2 中引入的锁屏小部件的引用时遇到了很多麻烦。

我创建了一个在启动器上运行良好的小部件,它的大小符合我的预期。但是,我已将此小部件启用到锁屏上,但它在垂直方向上的大小不正确。

根据 http://developer.android.com/guide/topics/appwidgets/index.html#lockscreen如果您设置 android:resizeMode="vertical"

,它将占用垂直可用的大小

If the widget marks itself as vertically resizable, then the widget height shows up as "small" on portrait phones displaying an unlock UI. In all other cases, the widget sizes to fill the available height.

我还使用了 http://developer.android.com/guide/practices/ui_guidelines/widget_design.html 中描述的尺寸

瓷砖 > 尺寸

  • 1 > 40dp
  • 2 > 110dp
  • 3 > 180dp
  • 4 > 250dp
  • ……>……
  • n > 70 × n − 30

我已经设置了这个并且看起来比“小”小部件还要小。基本上,有谁知道 image 1 中的小部件有什么问题,它不会展开?我的代码如下。

1) 默认状态下的样子。

enter image description here

2) 在另一个屏幕上展开时的样子。

enter image description here

xml/clock_widget.xml

<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
    android:initialKeyguardLayout="@layout/clock_widget"
    android:initialLayout="@layout/clock_widget"
    android:minHeight="110dp"
    android:minWidth="180dp"
    android:resizeMode="vertical"
    android:updatePeriodMillis="1000"
    android:widgetCategory="keyguard|home_screen" >

</appwidget-provider>

layout/clock_widget.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/clock_widget"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/widget_hour"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text=""
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textSize="36sp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text=":"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textSize="36sp" />

        <TextView
            android:id="@+id/widget_minute"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text=""
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textSize="36sp" />

    </LinearLayout>

    <TextView
        android:id="@+id/widget_date"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:text=""
        android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>

最佳答案

看起来这只发生在模拟器中。在真实硬件上测试工作正常。

关于android - 锁屏小部件太小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13595990/

相关文章:

java - MQTT 从主线程发送消息

android - 有没有像ICS的解锁屏一样 "Drag and Drop to unlock"组件的开源项目?

android - 如何用半透明 View 覆盖 ImageView?

android - 如何在 Android 的单元测试中模拟 Picasso?

android - 如何从 AutoCompleteTextView 获取字符串文本?

Android Gallery 小部件 "jitter"/"jumping"/表现怪异

android - bottone1 无法解析或不是字段

android - 如何将动态创建的LinearLayout添加到ScrollView中?

安卓相机X。开始抓拍后如何修改相机参数?

java - 定期扫描用户位置并更新本地数据库的后台进程,即使在应用程序未打开时也是如此