문제

I have written a SmartWatch 2 control extension which runs fine, but I am seeing a different font size when the application is installed on different phones. Most of the time the font is displayed correctly, but on some phones, the font on the SmartWatch is unusually large.

Here is the XML of the text widget:

<TextView
    android:id="@+id/watch_main_text"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_below="@+id/watch_title_bar"
    android:gravity="center"
    android:padding="5dp"
    android:text="@string/watch_choose_workout_string"
    android:textColor="@color/white"
    android:textSize="10sp" />

Is there some sort of global font size setting that overrides the font size specified in the XML resource?

Thanks!

도움이 되었습니까?

해결책

Try defining your textSize in terms of px and not sp. The reason the font size varies from phone to phone is because since the extension is actually running on the phone and not on the watch, it will try to scale the assets according to the phone even though the watch itself is a constant size.

Best way to do it is to use the @dimen constants defined in the SmartExtensionUtils project.

For example: android:textSize="@dimen/smart_watch_2_text_size_large"

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top