我在查找 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) 默认状态下的样子。
2) 在另一个屏幕上展开时的样子。
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/