Попробуйте добавить файл «attrs.xml» в папку «res / values».
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="MyAttrs">
<attr name="bufferTop" format="dimension" />
<attr name="myColor" format="color" />
<attr name="myInt" format="integer" />
<attr name="myFloat" format="float" />
</declare-styleable>
</resources>
Читайте по этому коду:
public baseGrid(Context contxt, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.MyAttrs);
bufferTop = a.getInt(R.styleable.MyAttrs_bufferTop, 10);
a.recycle();
}
Определите виджеты следующим образом:
<?xml version="1.0" encoding="utf-8"?>
< YOURPACKAGE.BaseGrid
android:background="@drawable/red"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:bufferTop="100"/>