2012-11-28 60 views
3

我在查找Android 4.2中引入的锁屏小工具引用时遇到了很多问题。锁屏小工具太小

我创建了一个在发射器上正常工作的小部件,它的大小与我的预期相当。不过,我已将这个小部件放置在锁屏上,并且它的大小不能垂直。

根据http://developer.android.com/guide/topics/appwidgets/index.html#lockscreen它会占用可用大小垂直如果设置android:resizeMode="vertical"

如果物件本身标记为垂直可调整大小,然后将小部件 高度显示为“小”纵向手机上显示解锁UI。 在所有其他情况下,小部件大小将填充可用高度。

另外我曾经在http://developer.android.com/guide/practices/ui_guidelines/widget_design.html

瓷砖描述的上浆>尺寸

  • 1> 40dp
  • 2> 110dp
  • 3> 180dp
  • 4> 250dp
  • ...> ...
  • N> 70×N - 30

我已经设置此,在似乎比 “小” 部件更小。基本上,没有人知道它在图片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> 

布局/ 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> 
+0

您是否尝试将minHeight添加到根LinearLayout? –

回答

1

看起来这只是在模拟器中发生。在真实的硬件上测试很好。

+0

好吧,我已经在使用我的小部件的Genymotion虚拟设备中看到过这个问题,并且询问了一个智能手机的用户,并且问题依然存在。你在说什么“真正的硬件”时,你在说什么? –

+0

它在Galaxy Nexus,Nexus 4和Nexus 7下正常工作。它无法在Galaxy Nexus的配置模拟器上工作。 – Kirk

+0

奇怪...所有这些设备都附带了股票启动器。你是否说你的小部件看起来像图像2中的那个一直?AFAIK肖像手机上的初始显示很小,并且一旦向下滑动锁定,它就会展开 –