Android get gravity value of textView programmically -
i'm trying current gravity value of textview in android
i searched lot on stackoverflow, found solutions how set gravity or how things margin, padding etc.
so how can current gravity of textview?
edit: it's getgravity()
this textview
:
<textview android:id="@+id/textview" android:gravity="center" android:text="hello world!" android:layout_width="wrap_content" android:layout_height="wrap_content" />
this method how getting gravity.
textview = (textview)findviewbyid(r.id.textview); switch (textview.getgravity()) { case gravity.center: toast.maketext(mainactivity.this, "center" , toast.length_short).show(); break; case gravity.top: toast.maketext(mainactivity.this, "top" , toast.length_short).show(); break; case gravity.bottom: toast.maketext(mainactivity.this, "bottom" , toast.length_short).show(); break; case gravity.center_horizontal: toast.maketext(mainactivity.this, "center_horizontal" , toast.length_short).show(); break; case gravity.center_vertical: toast.maketext(mainactivity.this, "center_vertical" , toast.length_short).show(); break; }
i getting toast
displaying center.
Comments
Post a Comment