What is the correct way to detect the gravity flags used for an XML item? I'm trying to achieve the following:
- If the gravity of my
TableLayout
(myTbl) is set toGravity.TOP
, then I want the gravity to be set toGravity.CENTER_VERTICAL
- Else if the gravity of my
TableLayout
(myTbl) is set toGravity.CENTER_VERTICAL
, then I want the gravity to be set toGravity.BOTTOM
private Button myBtn;
private TableLayout myTbl;
public void btn_click(View view) {
if (myTbl.getGravity() == Gravity.TOP) {
myTbl.setGravity(Gravity.CENTER_VERTICAL);
} else if (myTbl.getGravity() == Gravity.CENTER_VERTICAL) {
tblMain.setGravity(Gravity.BOTTOM);
}
}
I tried using getGravity()
but API 24+ is required, which is not what I want.The API used in my project is lower than 24.
Aucun commentaire:
Enregistrer un commentaire