Last active
December 22, 2016 03:30
-
-
Save amondnet/7772837 to your computer and use it in GitHub Desktop.
화면 중앙에 Rounded Toast 를 띄우기 위한 Class 작성.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.farmers.common.toast; | |
import android.app.Activity; | |
import android.view.Gravity; | |
import android.view.View; | |
import android.widget.TextView; | |
import android.widget.Toast; | |
import com.kpga.golfstroy.R; | |
/** | |
* The Class CenterToast | |
* | |
* 화면 중간에 Toast 를 띄우기 위한 Helper Class 입니다. | |
* | |
* @author amond ([email protected], [email protected] ) | |
* @see http://farmers.io or http://amond.net | |
* @version 1.0 | |
* | |
*/ | |
public class CenterToast { | |
/** The m toast. */ | |
static Toast mToast; | |
/** The shown. */ | |
static boolean shown = false; | |
/** | |
* make. | |
* | |
* @param activity the activity | |
* @param text Toast 에 보여지는 text | |
* @param duration Toast 가 보여지는 시간 | |
*/ | |
public static void make(Activity activity, String text, int duration) { | |
if (mToast != null) | |
mToast.cancel(); | |
View toastRoot = activity.getLayoutInflater().inflate(R.layout.v_toast, null); | |
TextView tv_Text = (TextView) toastRoot.findViewById(R.id.v_toast_text); | |
tv_Text.setText(text); | |
mToast = new Toast(activity); | |
mToast.setView(toastRoot); | |
mToast.setDuration(duration); | |
mToast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL, | |
0, 0); | |
mToast.show(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<shape xmlns:android="http://schemas.android.com/apk/res/android" > | |
<padding | |
android:bottom="15dp" | |
android:left="15dp" | |
android:right="15dp" | |
android:top="15dp" /> | |
<corners android:radius="8dp" /> | |
<!-- 투명도 70 --> | |
<solid android:color="#46333333" /> | |
</shape> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:background="@drawable/toast" | |
android:orientation="vertical" > | |
<TextView | |
android:id="@+id/v_toast_text" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center_vertical" | |
android:textSize="20sp" /> | |
</LinearLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment