Mats Willemsen Mats Willemsen - 3 years ago 85
Android Question

Dumped XML Layout File padding positions not behaving correctly

I've been trying to figure out how to make some sense of a dumped XML layout, and it's progressing 'pretty good'. The only thing I'm currently unsure about is the following:

When I use the command:

aapt dump xmltree <pathofapk> <pathofxmlfile>


I get the following result:

N: android=http://schemas.android.com/apk/res/android
E: LinearLayout (line=2)
A: android:orientation(0x010100c4)=(type 0x10)0x1
A: android:layout_width(0x010100f4)=(type 0x10)0xffffffff
A: android:layout_height(0x010100f5)=(type 0x10)0xffffffff
E: LinearLayout (line=7)
A: android:orientation(0x010100c4)=(type 0x10)0x0
A: android:background(0x010100d4)=@0x7f020004
A: android:layout_width(0x010100f4)=(type 0x10)0xffffffff
A: android:layout_height(0x010100f5)=(type 0x10)0xfffffffe
E: ImageView (line=12)
A: android:gravity(0x010100af)=(type 0x11)0x3
A: android:layout_gravity(0x010100b3)=(type 0x11)0x13
A: android:id(0x010100d0)=@0x7f090021
A: android:paddingLeft(0x010100d6)=(type 0x5)0xa01
A: android:paddingTop(0x010100d7)=(type 0x5)0x401
A: android:layout_width(0x010100f4)=(type 0x10)0xfffffffe
A: android:layout_height(0x010100f5)=(type 0x10)0xfffffffe
A: android:src(0x01010119)=@0x7f020006
E: ScrollView (line=21)
A: android:orientation(0x010100c4)=(type 0x10)0x1
A: android:layout_width(0x010100f4)=(type 0x10)0xffffffff
A: android:layout_height(0x010100f5)=(type 0x10)0xffffffff
A: android:layout_weight(0x01010181)=(type 0x4)0x3f800000
E: LinearLayout (line=25)
A: android:orientation(0x010100c4)=(type 0x10)0x1
A: android:id(0x010100d0)=@0x7f09002d
A: android:padding(0x010100d5)=(type 0x5)0xa01
A: android:layout_width(0x010100f4)=(type 0x10)0xffffffff
A: android:layout_height(0x010100f5)=(type 0x10)0xffffffff
E: EditText (line=29)
A: android:layout_gravity(0x010100b3)=(type 0x11)0x51
A: android:id(0x010100d0)=@0x7f09002e
A: android:layout_width(0x010100f4)=(type 0x10)0xffffffff
A: android:layout_height(0x010100f5)=(type 0x10)0xfffffffe
A: android:text(0x0101014f)="" (Raw: "")
A: android:hint(0x01010150)=@0x7f070050
E: EditText (line=36)
A: android:layout_gravity(0x010100b3)=(type 0x11)0x51
A: android:id(0x010100d0)=@0x7f09002f
A: android:layout_width(0x010100f4)=(type 0x10)0xffffffff
A: android:layout_height(0x010100f5)=(type 0x10)0xfffffffe
A: android:text(0x0101014f)="" (Raw: "")
A: android:hint(0x01010150)=@0x7f070051
A: android:password(0x0101015c)=(type 0x12)0xffffffff
E: LinearLayout (line=44)
A: android:orientation(0x010100c4)=(type 0x10)0x0
A: android:padding(0x010100d5)=(type 0x5)0xa01
A: android:layout_width(0x010100f4)=(type 0x10)0xffffffff
A: android:layout_height(0x010100f5)=(type 0x10)0xfffffffe
E: Button (line=48)
A: android:id(0x010100d0)=@0x7f090030
A: android:layout_width(0x010100f4)=(type 0x10)0xffffffff
A: android:layout_height(0x010100f5)=(type 0x10)0xfffffffe
A: android:text(0x0101014f)=@0x7f07000a
A: android:layout_weight(0x01010181)=(type 0x4)0x3f800000
E: Button (line=54)
A: android:id(0x010100d0)=@0x7f090031
A: android:layout_width(0x010100f4)=(type 0x10)0xffffffff
A: android:layout_height(0x010100f5)=(type 0x10)0xfffffffe
A: android:text(0x0101014f)=@0x7f070003
A: android:layout_weight(0x01010181)=(type 0x4)0x3f800000


That's all good, but what I'm trying to figure out is how to convert the following code into the XML layout file:

A: android:paddingLeft(0x010100d6)=(type 0x5)0xa01
A: android:paddingTop(0x010100d7)=(type 0x5)0x401


Converting those values to decimal would result in:

paddingLeft:2561
paddingTop:1025


All good, but I've been trying to figure out what the (type 0x5 means). With all other types, the result is defined in the Android.util.TypedValue.class file

Decompiling that, gives the following result for 0x5:

// Field descriptor #8 I
public static final int TYPE_DIMENSION = 5;


Makes sense, in a way. But, I need to know what kind of value it is, so looking down, I find the following value:

// Field descriptor #8 I
public static final int COMPLEX_UNIT_MM = 5;


But, when I try to use 2561mm and 1025mm (It's a tad much anyway, 25cm is.. larger than my screen), The whole screen is filled with the 'parent LinearLayout'.

I have no clue what's wrong. Can anyone enlighten me on this subject?

Answer Source

The data structure for these typed values is defined here:

https://android.googlesource.com/platform/frameworks/base/+/gingerbread-release/include/utils/ResourceTypes.h#220

Inside is an enum of the type codes; after that are definitions of the bits for fraction and unit types. (What you are seeing here are unit types -- i.e., 20sp.)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download