Show toast widget underneath a view

后端 未结 6 1772
别那么骄傲
别那么骄傲 2020-11-29 12:05

For those who helped me out earlier regarding this project, thank you very much! My code no longer has any problems, and I made extra tweaks. Now that the app is actually ro

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-29 13:11

    None of the answers did the job to me, i made a combination of the above answers and I got the solution down.

    enter image description here

    The second timer is the target view.

     public static void displayToastUnderView(Activity activity, View view, String text) {
            Toast toast = Toast.makeText(activity, text, Toast.LENGTH_SHORT);
            toast.setGravity( Gravity.TOP, view.getLeft() - view.getWidth() / 2 - toast.getView().getWidth() / 2, view.getBottom());
            toast.show();
        }
    

提交回复
热议问题