Can't get gravity attribute (android:gravity
) from my CustomView.
XML
<MyCustomView
...
android:gravity="right"
/>
My Custom View;
class MyCustomView extends LinearLayout{
...
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
getGravity(); //Throws method not found exception
((LayoutParams)getLayoutParams()).gravity; //This returns the value of android:layout_gravity
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
...
}
getGravity();
throws method not found exception;
((LayoutParams)getLayoutParams()).gravity;
returns the value of android:layout_gravity
Is there anyway I can get the gravity attribute from the view?