我想用dimens xml创建textview以设置大小以支持多个屏幕,但是当我在textview上调用dimen时,它不起作用。
这是我在values-sw600dp
文件夹上的尺寸:
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="text_size">12sp</dimen>
<dimen name="font_size">12sp</dimen>
</resources>
这是我打电话给textview的时候:
<TextView
android:id="@+id/testText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Created by :"
android:textSize="@dimen/font_size"/>
和logcat:
E/Dynamiclayout(9229): java.lang.IndexOutOfBoundsException: charAt: 0 >= length 0
我试图在https://gist.github.com/pyricau/3424004中使用自定义文字视图 但是logcat和dimens.xml中的相同错误在该textview上不起作用
提前致谢
编辑: 更多stacktrace:
04-09 12:26:54.585: E/Dynamiclayout(9607): java.lang.IndexOutOfBoundsException: charAt: 0 >= length 0
04-09 12:26:54.593: E/Dynamiclayout(9607): java.lang.IndexOutOfBoundsException: charAt: 0 >= length 0
04-09 12:26:54.593: E/Dynamiclayout(9607): java.lang.IndexOutOfBoundsException: charAt: 0 >= length 0
04-09 12:26:54.593: E/Dynamiclayout(9607): java.lang.IndexOutOfBoundsException: charAt: 0 >= length 0
04-09 12:26:54.593: E/Dynamiclayout(9607): java.lang.IndexOutOfBoundsException: charAt: 0 >= length 0
04-09 12:26:54.593: E/Dynamiclayout(9607): java.lang.IndexOutOfBoundsException: charAt: 0 >= length 0
04-09 12:26:54.593: E/Dynamiclayout(9607): java.lang.IndexOutOfBoundsException: charAt: 0 >= length 0
04-09 12:26:54.616: D/libEGL(9607): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
04-09 12:26:54.647: D/libEGL(9607): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
04-09 12:26:54.663: D/libEGL(9607): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
04-09 12:26:54.890: D/OpenGLRenderer(9607): Enabling debug mode 0
04-09 12:26:54.897: E/Dynamiclayout(9607): java.lang.IndexOutOfBoundsException: charAt: 0 >= length 0
04-09 12:26:54.897: E/Dynamiclayout(9607): java.lang.IndexOutOfBoundsException: charAt: 0 >= length 004-09 12:27:02.788: I/service(9607): services created