마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

토스트 가운데 정렬하는 법 좀 가르쳐주세요

0 추천
setGravity 이런게 안되더라구요ㅠ
초보개발자z (1,480 포인트) 님이 2014년 12월 26일 질문

1개의 답변

0 추천

제가 토스트 자체의 위치를 바꿔본 적은 없습니다만, 설명을 보면 setGravity로 이동가능하다고 나오는데요.

구글 디벨로퍼의 설명 부분 퍼왔습니다.

Positioning your Toast


A standard toast notification appears near the bottom of the screen, centered horizontally. You can change this position with the setGravity(int, int, int) method. This accepts three parameters: a Gravity constant, an x-position offset, and a y-position offset.

For example, if you decide that the toast should appear in the top-left corner, you can set the gravity like this:

toast.setGravity(Gravity.TOP|Gravity.LEFT, 0, 0);

If you want to nudge the position to the right, increase the value of the second parameter. To nudge it down, increase the value of the last parameter.

cc1232 (35,280 포인트) 님이 2014년 12월 26일 답변
...