im using below methods and im getting android.content.res.Resources$NotFoundException: Resource ID #0x7f070187 type #0x4 is not valid. Code:
float pageMargin = getResources().getDimensionPixelOffset(R.dimen.pageMargin);
float pageOffset = getResources().getDimensionPixelOffset(R.dimen.offset);
<dimen name="pageMargin">20</dimen>
<dimen name="offset">30</dimen>
Any help is appreciated!
Ensure the dimensions have a defined unit:
https://developer.android.com/guide/topics/resources/more-resources#Dimension
In your case do as next. Notice the dp postfix after each value:
<dimen name="pageMargin">20dp</dimen>
<dimen name="offset">30dp</dimen>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.