我有这样的习惯View
:
public class ShadowTextView extends TextView {
...
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
final int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
final int parentHeight = MeasureSpec.getSize(heightMeasureSpec);
final int minSize = Math.min(parentWidth, parentHeight);
mShadow = new Paint(Paint.ANTI_ALIAS_FLAG);
RadialGradient gradient = new RadialGradient(
parentWidth * mCenterX,
parentHeight * mCenterY,
minSize * mGradientRadiusWidthPercent,
new int[]{mStartColor, mCenterColor, mEndColor},
null,
android.graphics.Shader.TileMode.CLAMP);
mShadow.setDither(true);
mShadow.setShader(gradient);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawRect(0, 0, getWidth(), getHeight(), mShadow);
}
...
}
Run Code Online (Sandbox Code Playgroud)
在XML格式中,我希望将它CustomView …
使用以下代码使视图模糊的背景不能始终如一地工作.
func makeBackgroundBlurry () {
var blurEffect = UIBlurEffect()
blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = view.bounds //view is self.view in a UIViewController
view.insertSubview(blurEffectView, atIndex: 0)
view.backgroundColor = UIColor.clearColor()
//add auto layout constraints so that the blur fills the screen upon rotating device
blurEffectView.setTranslatesAutoresizingMaskIntoConstraints(false)
view.addConstraint(NSLayoutConstraint(item: blurEffectView, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.Top, multiplier: 1, constant: 0))
view.addConstraint(NSLayoutConstraint(item: blurEffectView, attribute: NSLayoutAttribute.Bottom, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.Bottom, multiplier: 1, constant: 0))
view.addConstraint(NSLayoutConstraint(item: blurEffectView, attribute: NSLayoutAttribute.Leading, …
Run Code Online (Sandbox Code Playgroud) 我一直在探索谷歌图表的功能,现在我正在尝试自定义散点图.我有以下功能:
function drawScatterChart(){
var data = google.visualization.arrayToDataTable([
['Chance', 'Impact'],
[ 5, 4],
[ 1, 2]
]);
var options = {
hAxis: {title: 'Chance', minValue: 0, maxValue: 5},
vAxis: {title: 'Impact', minValue: 0, maxValue: 5},
legend: 'none',
'chartArea' : { 'backgroundColor' : '#F4F4F4' }
};
var chart = new google.visualization.ScatterChart(document.getElementById('scatter_chart'));
chart.draw(data, options);
}
Run Code Online (Sandbox Code Playgroud)
这成功地将chartArea的背景颜色更改为灰色,这很棒.但现在我想实现一个从图表的左下角到右上角的渐变,包含3种颜色(绿色到黄色到红色).
有没有办法将其破解到图表中,因为我一直试图在文档中找到任何内容,只能找到一些旧文档(即:https://developers.google.com/chart/image/docs/chart_params)但无法找到实现这一目标的方法.
谢谢!
我有一个装有Image
和的图像ImageView
.
我想制作图像的背景,这是白色的,透明的,以匹配背景.
我正在开发一个提供背景信标监控的应用程序.当用户从定义的区域输入信标时,我想开始测距.当应用程序处于后台并且它一直在监视并且用户进入我定义的区域时,我想开始测距并获得InstanceID或Major,Minor值来确定信标是什么,连接到服务器并向用户发送通知.如果我可以在后台与服务器进行通信,那将是最好的.我使用此示例来实现后台监视:https://altbeacon.github.io/android-beacon-library/samples.html.我还从这里下载了示例项目:https://github.com/AltBeacon/android-beacon-library-reference以此为基础.
不幸的是,在此示例中,当用户进入区域时,Activity已启动...我不希望这种情况发生.所以我的问题是:是否有可能在背景中放置信标?
在我的情况下也发生了奇怪的事情,因为当我把我的应用程序放在后台方法"didRangeBeaconsInRegion(集合信标,区域区域)"仍然从MainActivity调用但没有找到信标.此外,方法的调用次数较少,因为beaconManager处于后台模式.当我启动未发生的示例项目时.也许是因为我没有monitoringActivity.我的MainActivity在推出时会立即进行测距.当然,我尝试设置与BeaconReferenceApplication示例完全相同的一切.
顺便说一下,我正在使用Android 6.0.1在Nexus 5上测试我的应用程序
提前感谢您提供任何解决方案!
我从服务器向我的应用程序发送fcm通知.
我从服务器发送包含user_id的数据.如果应用程序位于前台,我将在FirebaseMessageService类中获取此userId.但是,当应用程序处于后台时,不会得到它.由于FirebaseMessagingService类仅在应用程序位于前台时才会执行.
那么当应用程序处于后台时,如何获得此ID?
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG = "MyFirebaseMsgService";
private String mUserId;
private Boolean mUpdateNotification;
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
//Displaying data in log
//It is optional
Log.d(TAG, "From: " + remoteMessage.getFrom());
Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody());
String clickAction = remoteMessage.getNotification().getClickAction();
mUserId = remoteMessage.getData().get("user_id");
String title = remoteMessage.getNotification().getTitle();
//Calling method to generate notification
sendNotification(remoteMessage.getNotification().getBody(),clickAction,title);
}
//This method is only generating push notification
//It is same as we did in earlier …
Run Code Online (Sandbox Code Playgroud) 我有一个带有几个表和白色应用程序背景的应用程序,可以与使用过的徽标混合使用.我已经将所有背景设置为白色但是到目前为止还有一个我无法达到的空间.
使用标准JTable我可以移动列,这是完全没问题的.但是,移动列时,您仍然可以看到TableHeaders背后的标准应用程序颜色.在JScrollPane中显示我认为设置背景ScrollPane.getContentHeader()
会有所帮助,但我得到了一个NPE.
下面是一个应该显示问题的小程序:
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
public class testsforSO extends JFrame {
private static final long serialVersionUID = -3890178393751567629L;
private JTable table;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
testsforSO frame = new testsforSO();
frame.setSize(300, 300);
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public testsforSO() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setLayout(new BorderLayout(0, 0));
JScrollPane scrollPane = …
Run Code Online (Sandbox Code Playgroud) 当我把以下内容放入div
主要内容时body
,这个工作:
<div style="display: block; width:100%; height: 100%; min-height: 100vh; background-color: #FFFFFF; background: url(./images/pic.jpg); background-position: center; background-repeat: no-repeat; background-size: cover; background-attachment: fixed;">
Run Code Online (Sandbox Code Playgroud)
但是,当我使用CSS时,它不工作:
<style type="text/css" media="all">
.myMainDiv {
width:100%;
height: 100%;
min-height: 100vh;
background-color: #FFFFFF;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
}
</style>
<div class="myMainDiv" style="display: block; background: url(./images/pic.jpg);">
Run Code Online (Sandbox Code Playgroud)
这似乎是错误的,因为我需要为每个背景提供不同的图片,然后这会导致background-repeat
等等被忽略.(注意:不同的div也会有不同的显示值,无论是块还是无,所以它们也需要单独说明,但这不是问题.)
任何人都知道为什么以及是否有解决方法.
css background background-position background-repeat background-size
我是python语言的新手,我一直在学习tkinter.但是我想知道如何更改tkinter中弹出的框的背景.
import time
import tkinter
from tkinter import *
import sys
import os
root = tkinter.Tk()
Run Code Online (Sandbox Code Playgroud)
使用它你会弹出一个灰色框.如何更改该盒子的颜色?
我正在与matplotlib
图书馆PyQt5
合作Python 3.6
.我在我创建的窗口中添加了一个图形,并且我希望将此图形的背景设置为透明,因为我将图像添加到窗口的背景中.但是,这个数字并不是真正透明,它复制了窗口的背景图像.例如,有人在两年前处理同样的问题:
matplotlib和pyqt4透明背景
这是一个工作示例(背景为黑色,但图形不是黑色):
import sys, os
from PyQt5.QtCore import Qt
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import matplotlib
matplotlib.use('Qt5Agg') # Make sure that we are using QT5
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from matplotlib.figure import Figure
import matplotlib.pyplot as plt
class SecondWindow(QWidget):
def __init__(self, parent=None):
super(SecondWindow, self).__init__(parent)
self.setupUi(self)
def setupUi(self, Form):
# WINDOW SETTINGS
Form.setWindowTitle('Hello')
self.p = QPalette()
self.pixmap = QPixmap(os.getcwd() + "/logo.png").scaled(self.size(), Qt.IgnoreAspectRatio, …
Run Code Online (Sandbox Code Playgroud) background ×10
android ×3
java ×3
altbeacon ×1
canvas ×1
colors ×1
css ×1
fill ×1
firebase ×1
gradient ×1
image ×1
ios ×1
javafx ×1
jtable ×1
matplotlib ×1
pyqt ×1
python ×1
svg ×1
swift ×1
swing ×1
tkinter ×1
transparency ×1
transparent ×1
uiblureffect ×1