mirror of
https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git
synced 2025-02-24 10:12:53 +08:00
#60 Is it possible to change the android theme?
This commit is contained in:
parent
03320113b4
commit
6ee16e9e7d
@ -2,7 +2,7 @@
|
|||||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
id="cordova-plugin-x-toast"
|
id="cordova-plugin-x-toast"
|
||||||
version="2.2.1">
|
version="2.2.2-dev">
|
||||||
|
|
||||||
<name>Toast</name>
|
<name>Toast</name>
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package nl.xservices.plugins;
|
package nl.xservices.plugins;
|
||||||
|
|
||||||
|
import android.graphics.Color;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import org.apache.cordova.CallbackContext;
|
import org.apache.cordova.CallbackContext;
|
||||||
import org.apache.cordova.CordovaPlugin;
|
import org.apache.cordova.CordovaPlugin;
|
||||||
@ -52,10 +53,13 @@ public class Toast extends CordovaPlugin {
|
|||||||
cordova.getActivity().runOnUiThread(new Runnable() {
|
cordova.getActivity().runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
android.widget.Toast toast = android.widget.Toast.makeText(
|
android.widget.Toast toast = android.widget.Toast.makeText(
|
||||||
cordova.getActivity().getApplicationContext(),
|
cordova.getActivity().getWindow().getContext(),
|
||||||
message,
|
message,
|
||||||
"short".equals(duration) ? android.widget.Toast.LENGTH_SHORT : android.widget.Toast.LENGTH_LONG);
|
"short".equals(duration) ? android.widget.Toast.LENGTH_SHORT : android.widget.Toast.LENGTH_LONG);
|
||||||
|
|
||||||
|
// toast.getView().setBackgroundColor(Color.GRAY);
|
||||||
|
// toast.getView().setPadding(20, 10, 20, 10);
|
||||||
|
toast.getView().getBackground().setTint(Color.DKGRAY);
|
||||||
if ("top".equals(position)) {
|
if ("top".equals(position)) {
|
||||||
toast.setGravity(Gravity.TOP|Gravity.CENTER_HORIZONTAL, 0, 20 + addPixelsY);
|
toast.setGravity(Gravity.TOP|Gravity.CENTER_HORIZONTAL, 0, 20 + addPixelsY);
|
||||||
} else if ("bottom".equals(position)) {
|
} else if ("bottom".equals(position)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user