我的应用程序以 3x3 的简单网格呈现数字 1-9 的简单屏幕。您可以在此处查看我的 SmartWatch 上的外观:https ://www.youtube.com/watch?v=ijh5EOTTR-w
现在,这一切都是正确的。问题是用户报告了他的设备上同一个应用程序的不同显示,可以在这里看到:https ://docs.google.com/open?id=0BwywSxPvL53dcmlwd0RJQWhVa0E
两款智能手表都在相同的版本上运行:
- 智能手表版本 0.1.A.3.7
- 主机应用程序 1.2.37
唯一的区别是手机型号:问题出现在 Sony Xperia S 上,而在 Sony Xperia Sola 上一切正常。这两款手机都运行索尼的 Android Gingerbread(在升级到 ICS 后,Sola 上的所有手机都可以正常工作)。
我尝试以不同的方式指定数字(文本)的大小,使用 dip、px、mm,但在所有情况下,在 Sola 上它们的尺寸都比在 Xperia S 上小得多。
我不知道是什么造成了这种显着差异,并希望得到任何提示或帮助。谢谢!
PS我没有使用任何drawables。
这是我的代码,可以使事情更加清晰:
1)保存值的网格:
<?xml version="1.0" encoding="utf-8"?>
<!-- px is used since this is a layout for the accessory display. -->
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/smart_watch_control_height"
android:layout_height="@dimen/smart_watch_control_width"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="PxUsage">
<GridView
android:id="@+id/grid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginRight="0px"
android:layout_marginTop="-13px"
android:columnWidth="40px"
android:gravity="center"
android:horizontalSpacing="0dip"
android:numColumns="3"
android:padding="0dip"
android:stretchMode="none"
android:verticalSpacing="0dip" />
</RelativeLayout>
2)在网格的每个单元格中都有以下元素之一:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="16dip"
android:textStyle="bold"
android:textColor="#0000FF"
android:gravity="center"
android:padding="0dip"
/>
3)控件中的绘制逻辑:
// Create background bitmap for animation.
background = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
// Set default density to avoid scaling.
background.setDensity(DisplayMetrics.DENSITY_DEFAULT);
LinearLayout root = new LinearLayout(mContext);
root.setLayoutParams(new LayoutParams(width, height));
LinearLayout sampleLayout= (LinearLayout) LinearLayout.inflate(mContext,
R.layout.speed_dial_control, root);
// draw on the sampleLayout
GridView gridView = (GridView) sampleLayout.findViewById(R.id.grid);
gridView.setAdapter(adapter);
// adjust the size
sampleLayout.measure(width, height);
sampleLayout.layout(0, 0, sampleLayout.getMeasuredWidth(),
sampleLayout.getMeasuredHeight());
// Draw on canvas
Canvas canvas = new Canvas(background);
sampleLayout.draw(canvas);
// Send bitmap to accessory
showBitmap(background);