在我的游戏中,我有 3 个活动:主菜单 -> 子菜单 -> 游戏屏幕。因此,当用户在游戏屏幕中玩游戏时,前两个活动处于非活动状态,但不会被销毁。
每个布局都有一个漂亮的背景图像。图像本身非常小(40k),但在大屏幕(比如 Galaxy 平板电脑)上,它占用了几兆内存。从前两个活动中去除背景后,第三个活动的内存使用量从 18M 下降到 13M!
有没有办法保留背景并恢复所有这些浪费的内存?
这是Linux。我创建了一个窗口,我想将其背景颜色更改为绿色。这是我的代码的样子:
Window xwin = XCreateSimpleWindow(dis,
DefaultRootWindow(dis),
0, 0,
500, 300,
0,
WhitePixel(dis, 0),
WhitePixel(dis, 0));
GC gc = XCreateGC(dis, xwin, 0, NULL);
XColor color;
Colormap colormap;
char green[] = "#00FF00";
colormap = DefaultColormap(dis, 0);
XParseColor(dis, colormap, green, &color);
XAllocColor(dis, colormap, &color);
XSetBackground(dis, gc, color.pixel);
XMapWindow(dis, xwin);
XFlush(dis);
Run Code Online (Sandbox Code Playgroud)
我看到的窗户是白色的。是否可以使用 X11 在 Linux 中更改窗口背景颜色?谢谢!
我正在开发一个 Java 项目来模拟直升机在框架中的飞行。直升机使用箭头键在屏幕上移动。我希望直升机能够无限移动,即当直升机到达画面边缘时,背景应该向相反的方向移动,以产生无尽地形的效果。
这是我到目前为止的代码:
import java.awt.Graphics;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.net.URL;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.*;
public class MainFrame extends JFrame
{
private static int FRAME_WIDTH = 800;
private static int FRAME_HEIGHT = 500;
public MainFrame()
{
add(new AnotherBackground(FRAME_WIDTH, FRAME_HEIGHT));
setTitle("Helicopter Background Test");
setSize(FRAME_WIDTH,FRAME_HEIGHT);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String[] args)
{
new MainFrame();
}
}
class AnotherBackground extends JPanel
{
private BufferedImage heliImage = null;
private BufferedImage backImage = null;
private int heliX …
Run Code Online (Sandbox Code Playgroud) 请帮助我们如何进行背景资源检查?
例子:
Button button1;
protected void onCreate(Bundle savedInstanceState) {
..........................................
button1 = (Button) findViewById(R.id.example1);
}
public void onclick1 (View v){
button1.setBackgroundResource(R.drawable.example2);
}
public void onclick2 (View v){
Run Code Online (Sandbox Code Playgroud)
我的问题在这里,检查 button1 按钮是否可绘制 = example2
if (..........................){
//Action
}
Run Code Online (Sandbox Code Playgroud)
如果没有,当点击时会做另一个动作
else {
//Another Action
}
}
Run Code Online (Sandbox Code Playgroud) 我开发了一个带有在后台运行的服务的 android 应用程序,该服务的调用方式是
startService(new Intent(getApplicationContext(),myService.class));
Run Code Online (Sandbox Code Playgroud)
但是当我从最近的应用程序中删除该应用程序时,如果我测试它,该服务会停止并崩溃..有没有办法防止从最近的应用程序中刷该应用程序时该服务被破坏?
谢谢你
我有 viewport3d,我想改变它的背景颜色。
我对 Wpf 很陌生。我从其他帖子中不明白该怎么做。所以我在这里问。
我更改了 viewport3d 的画笔属性,但它什么也没做
<Window x:Class="W3DTinker.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="800" Width="1200">
<Grid HorizontalAlignment="Left" Height="780" Margin="10,10,0,-21" VerticalAlignment="Top" Width="1180">
<Viewport3D Grid.Row="0" Grid.Column="0" x:Name="Viewport" Margin="350,10,10,10" OpacityMask="{DynamicResource {x:Static SystemColors.AppWorkspaceBrushKey}}" />
</Grid>
Run Code Online (Sandbox Code Playgroud)
我有一个Ionic-v4-app,侧面菜单结构如下:
<ion-app>
<ion-split-pane>
<ion-menu>
<ion-header>
<ion-toolbar>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
</ion-list>
</ion-content>
</ion-menu>
</ion-split-pane>
</ion-app>
Run Code Online (Sandbox Code Playgroud)
现在我希望有整个侧面菜单的背景(标题,列表,内容,一切).
但我没有必要尝试,我不知道它是如何工作的.
我尝试了背景颜色ion-menu
和透明背景header
和content
,也没有工作.
我知道我必须使用我必须使用离子css变量--ion-background-color
,但如何?
由于我需要在WorkManager中异步执行工作,因此我需要使用ListenableWorker
,默认情况下,它在主(UI)线程上运行。由于这项工作可能是很长时间的处理任务,可能会冻结接口,因此我想在后台线程上执行它。在使用WorkManager(Android Dev Summit '18)视频中,Google工程师展示了如何手动配置WorkManager以在自定义上运行作品Executor
,因此我遵循他的指导:
1)在AndroidManifest中禁用默认的WorkManager初始化程序:
<provider
android:name="androidx.work.impl.WorkManagerInitializer"
android:authorities="com.example.myapp.workmanager-init"
tools:node="remove" />
Run Code Online (Sandbox Code Playgroud)
2)在Application.onCreate中,使用自定义配置初始化WorkManager,在我的情况下是这样的:
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Configuration configuration = new Configuration.Builder().setExecutor(Executors.newSingleThreadExecutor()).build();
WorkManager.initialize(this, configuration);
}
}
Run Code Online (Sandbox Code Playgroud)
现在我的实际ListenableWorker
是这样的:
@NonNull
@Override
public ListenableFuture<Result> startWork() {
Log.d(TAG, "Work started.");
mFuture = ResolvableFuture.create();
Result result = doWork();
mFuture.set(result);
return mFuture;
}
private Result doWork() {
Log.d(TAG, "isMainThread? " + isMainThread());
mFusedLocationProviderClient.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
if …
Run Code Online (Sandbox Code Playgroud) performance android background android-architecture-components android-workmanager
我有一个我正在编写的CSS页面,我需要在一个类中应用背景图像,然后使用另一个类将部分透明的背景图像放在已经存在的那个上面.这有点沙拉,所以让我举一些示范.
html{
<div class="background1">...</div>
<div class="background1 backgroundFilter">...</div>
<div class="background2">...</div>
<div class="background2 backgroundFilter">...</div>
}
css {
.background1 {
background-image:url(...);
}
.background2 {
background-image:url(...);
}
.backgroundFilter {
background-image:url(...);
}
}
Run Code Online (Sandbox Code Playgroud)
在这个例子中,第一个div应该有背景图像1,第二个div应该有背景图像1但是滤镜图像放在它上面,然后第三个应该是图像2而第四个应该是图像2,其上有相同的滤镜.
但是在这个例子中,.backgroundFilter将覆盖前一个图像而不是覆盖它.
这是可能的还是我需要为每个版本的背景图像创建一个不同的类?
background ×10
android ×4
colors ×2
css ×2
java ×2
android-architecture-components ×1
audio ×1
c# ×1
drawable ×1
graphics2d ×1
html ×1
ios ×1
jpanel ×1
memory ×1
performance ×1
resources ×1
service ×1
side-menu ×1
swing ×1
view ×1
viewport3d ×1
window ×1
wpf ×1
x11 ×1
xlib ×1