I am trying to write unit test to verify the use of DIP. I can read the size value using editText.getTextSize (), but I cannot read the unit of text (in this case, it must ensure the use of "dp"). In test cases, someone changes the unit of text from dp to px or any other device.
<EditText android:id="@+id/someId" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="48dp"/>
Thanks in advance!
First, never run textSize on dp. They should always be used spso that people with vision problems can scale them as needed.
dp
sp
-, unit test ? ? , xml, ? Google, , . unit test - , . , ? , , dp vs px.
px
, dp . , . :
lintOptions { warningsAsErrors true abortOnError true // Fail early. }
@Gabe , Android. , , / xml.
xml
- , , . , , .
- ,