Link to static field from class in xml layouts in Android

Let's say I have the following TextViewin the layout:

<TextView
    android:id="@+id/txtLoginError"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/sz_12dp"
    android:gravity="center"
    android:text="@string/foo" />

Is it possible that I am modifying @dimen/sz_12dpto point to a static field in my custom class, for example:

public static class MyDimensions {
    public static int topMarginInPixels = 99; // which would be referenced in some fashion like android:layout_marginTop="@class/MyDimensions.topMarginInPixels"
}

Basically I am looking for a way to build the "databind" element for some experiments; instead of loading the view and then changing it in code ( findview, setWeightetc.). I would like during creation to retrieve dimensions from my custom class, it would extract it from R.java.

. , px dp, res/values ​​ , , , , , , .

+3
1

, , , px dp, XML, dimens - , .

EDIT , ; , LayoutParams , , , , .

+2

All Articles