我想开发一个应用程序,我想在其中设置可绘制文件夹中的背景图像。我希望我的活动何时运行,背景将是该图像。而且也不使用 XML。
谢谢。
我正在尝试在原始 html 页面之上创建一个灰色透明背景屏幕。到目前为止,我所做的是将一个 div (使用 jquery)附加到具有以下 css 样式的 body 标记:
.spesificPropertiesDiv {
position: absolute;
display: block;
top: 0px;
width: 100%;
height: 100%;
background-color: black;
opacity: 0.5;
z-index: 6000;
text-align: center;
}
Run Code Online (Sandbox Code Playgroud)
正如我之前提到的,我将一个包含此类的 div 添加到主体中。当我将其附加到大屏幕(24 英寸)上时,每个效果都很好,但是当我将其附加到 16 英寸显示屏上时,灰屏 div 的高度比主体高度小 100 px。我需要提到的另一件事是,在大屏幕上,页面适合屏幕,而在较小的屏幕上,会出现滚动条,使页面的下侧可见。
为什么会发生这种情况?我该如何修复它?谢谢!
我已经用谷歌搜索并阅读了很多内容,但没有找到适合我需要的答案,所以我会在这里问:
我想在我的 JFrame 中有一个渐变背景。目前背景是单色的。我的代码看起来像这样:
//imports
public class Game {
//some other irrelevant instance variables
JFrame frame = new JFrame("Game");
public Game() {
frame.getContentPane().setBackground(new Color(200,220,200));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(null);
frame.setPreferredSize(new Dimension(frameX,frameY)); //frameX and frameY are instance variables
getMenu(); //method that adds a few JLabels to the JFrame and so on
}
}
Run Code Online (Sandbox Code Playgroud)
我读过的方法适用于扩展 JPanel 或 JFrame 的类(然后使用 GradientPaint 或类似的东西),但正如您所看到的,我使用 JFrame 作为实例变量。有人可以帮我吗?
编辑: 图片:
div
我试图在使用之前:before
和之后放置图像:after
。不幸的是,我看不到图像。为什么?
这是代码(在jsfiddle中):
<div style="border:1px solid green; padding:50px;">
<div id="videos-part">test</div>
</div>
#videos-part{
height: 127px;
width: 764px;
border:1px solid red;
margin:30px;
padding:30px;
}
#videos-part:before{
width: 46px;
height:46px;
content: "before ";
background-image: url(http://aux.iconpedia.net/uploads/136059938344542682.png);
}
#videos-part:after{
width: 46px;
height:46px;
content: " after";
background-image: url(http://aux.iconpedia.net/uploads/136059938344542682.png);
}
Run Code Online (Sandbox Code Playgroud) 我想以编程方式更改主视图中的背景颜色(我正在使用 Swift 创建一个应用程序)。我尝试将此代码放入 viewDidLoad() 但它不起作用。这样做的正确方法是什么?
override func viewDidLoad() {
super.viewDidLoad()
...
let myBackground = UIView()
let colorWhite = UIColor(red: 255, green: 255, blue: 255, alpha: 1)
myBackground.backgroundColor = colorWhite
...
}
}
Run Code Online (Sandbox Code Playgroud) 我正在构建一个用户控件,它在 2x2 网格中有 4 个 Canvas。当我将网格的背景设置为某种颜色时,画布周围的颜色会发生变化,但画布的背景保持白色。
如何才能使画布组的背景透明并且可以看到网格的背景?我在这里找到了一些解释,但没有代码,我不明白如何让它工作。
编辑:这是 XAML 代码。正如您所看到的,我尝试<Canvas IsItemsHost="True" Background="{x:Null}"/>
在代码中设置最后一个列表框的画布,但这不起作用。设置Background="Transparent"
也不起作用。
<UserControl x:Class="ProgramEditor.objectPresenter.objectPresenter"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:objectPresenter="clr-namespace:ProgramEditor.objectPresenter"
xmlns:behavior="clr-namespace:RubberBand;assembly=RubberBand"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras"
d:DataContext="{d:DesignInstance objectPresenter:objectViewModel, IsDesignTimeCreatable=True}"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="700">
<UserControl.Resources>
<sys:Double x:Key="objectWidth">610</sys:Double>
<sys:Double x:Key="objectHeight">365</sys:Double>
<objectPresenter:HorizontalValueConverter x:Key="horizontalValueConverter" />
<objectPresenter:VerticalValueConverter x:Key="verticalValueConverter" />
<Style x:Key="RowColumnSelector" TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding IsSelected}" Value="True">
<Setter Property="Foreground" Value="Black"/>
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
</Style.Triggers>
<Setter Property="Cursor" Value="Hand"/>
</Style>
<DataTemplate DataType="{x:Type objectPresenter:TargetSelector}">
<TextBlock Width="{Binding HorizontalSize, Converter={StaticResource horizontalValueConverter}, ConverterParameter={StaticResource objectWidth}}"
Height="{Binding VerticalSize, Converter={StaticResource …
Run Code Online (Sandbox Code Playgroud) 我的 iOS 应用程序遇到了问题。即使我的应用程序不在 iPhone 的前台,我也想每天运行一个函数。我尝试使用NSTimer
Object 但如果我的应用程序在后台,它就不起作用。
我怎样才能做到这一点?
注意:我的函数将触发一个通知,该通知根据当天的不同而有所不同。
我必须通过后面的代码定义一个组合框:
var cmbLogin = new ComboBox()
{
Width = 200,
Height = m_dFontSize + 10,
FontSize = m_dFontSize,
Margin = new Thickness(20),
BorderBrush = new SolidColorBrush(m_ExeCfg.GetForeground()),
HorizontalContentAlignment = HorizontalAlignment.Center,
Background = Brushes.Transparent,<--------------HERE
Foreground = new SolidColorBrush(m_ExeCfg.GetForeground()),
Focusable = true,
};
Run Code Online (Sandbox Code Playgroud)
所以背景在win7中变得透明,但在win10中不是。
我已经通过 xaml 看到了一些解决方案,但不能仅将它们应用到代码中。谢谢
我遇到了奇怪的问题(对于我作为 CSS 世界的初学者来说)。我试图在其顶部有一个带有透明颜色的背景图像。图像是主页背景:
body {
font-family: 'Raleway', 'Open Sans', sans-serif;
font-weight: 400;
line-height: 1.6;
background: rgba(0,0,0,.3) url('..img/image.jpg') no-repeat;
background-size: cover;
min-height: 100vh; }
Run Code Online (Sandbox Code Playgroud)
这对我不起作用。不知道为什么?
我检查了开发工具,添加了单独的背景颜色,但效果不佳。我试图在这里找到解决方案:Semi-transparent color layer over background-image? 和 treid 提出的解决方案。不适合我。
但是当我添加类并创建此行时:
.body {
background:
linear-gradient(
rgba(0, 0, 0,.5),
rgba(0, 0, 0,.5)
),
url('../img/bg_image.jpg') no-repeat;
background-size: cover; }
Run Code Online (Sandbox Code Playgroud)
有效!但我还是不知道为什么?
是特异性问题吗?也许有什么不同?如果有人可以回答我的问题(以 qucik 为例),我将不胜感激。
所以我自己找到的解决方案是上面的代码,但我不明白之前的尝试对我不起作用。
干杯,卡米尔
css background background-image css-specificity background-color
我有一个使用 CoreLocation 和 WiFi SSID 信息的 iOS 应用程序。我的应用程序在 iOS 13 到来之前一直运行良好,但从那时起它给我带来了很多问题,尤其是当应用程序进入后台时。我一直在后台使用一个计时器作为后台任务,它在 30 秒后也不起作用,尤其是应用程序在同一时间范围内在后台被杀死。我看到有人说 iOS 13 对后台任务和时间安排很严格,但我仍然没有找到任何支持这种说法的苹果的直接参考或链接。有没有其他人面临同样的问题,然后请分享您的见解。谢谢
我有一个计时器的后台任务:
var bgTask: UIBackgroundTaskIdentifier?
var updateTimer: Timer?
func applicationDidEnterBackground(_ application: UIApplication) {
bgTask = application.beginBackgroundTask(withName: "MyTask", expirationHandler: {() -> Void in
if let bgTask = self.bgTask {
application.endBackgroundTask(bgTask)
self.bgTask = UIBackgroundTaskIdentifier(rawValue: convertFromUIBackgroundTaskIdentifier(UIBackgroundTaskIdentifier.invalid))
}
})
DispatchQueue.main.async(execute: {() -> Void in
self.updateTimer = Timer.scheduledTimer(timeInterval: 2.0, target: self, selector: #selector(self.checkNetworkStatus), userInfo: nil, repeats: true)
})
}
@objc func checkNetworkStatus() {
print("Timer calledddd")
}
Run Code Online (Sandbox Code Playgroud)