1
캔버스를 사용하여 라이브 벽지를 만들었습니다. (상대 레이아웃) 과 같은 레이아웃을 추가하고 싶습니다. 가능한 경우?안드로이드 라이브 월페이퍼에서 레이아웃을 추가하는 방법
라이브 벽지에서 레이아웃을 사용할 수 있습니까?
가능하면 레이아웃을 추가하는 방법을 안내해주세요. 가능하면 캔버스 클래스에서 레이아웃을 어떻게 호출 할 수 있습니까? 이 캔버스에 어떻게 ondraw mathod를 덮어 쓸 수 있습니까?
나는 홀 인터넷을 검색했다. 나는 어떤 정보도 잘 수 없다. 나는 안드로이드 라이브 벽지가 처음이다. 그리고 jave plz이 나를 인도한다. 다음은 항상 WallpaperService에 getTheme()를 호출하고 그에 레이아웃을 적용 할 수 있는지를 사용하지 않을 무엇 비록 당신에게 것이 내 캔버스 클래스
public class Aquarium {
private AquariumThread aquariumThread;
private SurfaceHolder surfaceHolder;
private ArrayList<Renderable> fishes;
private Bitmap backgroundImage, backgroundImage1;
private Bitmap boble;
public Boolean bgchange = false;
private Context context;
public int count = 1, x = 100, y = 500, x1 = 400, y1 = 500, x2 = 10,
y2 = 250;
public AquariumWallpaperEngine aqua;
public void render() {
Canvas canvas = null;
try {
count++;
if (count > 5) {
if (count % 8 == 0) {
x2++;
y--;
y1--;
}
}
if (y == -20) {
y = 600;
y1 = 600;
}
if (x2 == 700) {
x2 = -20;
}
if (count > 3000) {
bgchange = true;
}
if (count > 6000) {
bgchange = false;
count = 0;
}
//System.out.println("count" + count);
canvas = this.surfaceHolder.lockCanvas(null);
synchronized (this.surfaceHolder) {
this.onDraw(canvas);
}
} finally {
if (canvas != null) {
this.surfaceHolder.unlockCanvasAndPost(canvas);
}
}
}
protected void onDraw(Canvas canvas) {
this.renderBackGround(canvas);
for (Renderable renderable : this.fishes) {
renderable.render(canvas);
}
};
public void start() {
this.aquariumThread.switchOn();
}
public void stop() {
boolean retry = true;
this.aquariumThread.switchOff();
while (retry) {
try {
this.aquariumThread.join();
retry = false;
} catch (InterruptedException e) {
// we will try it again and again...
}
}
}
public int getLeft() {
return 0;
}
public int getRight() {
return this.backgroundImage.getWidth();
}
public int getRightbg() {
return this.backgroundImage1.getWidth();
}
public void initialize(Context context, SurfaceHolder surfaceHolder) {
this.aquariumThread = new AquariumThread(this);
this.surfaceHolder = surfaceHolder;
this.fishes = new ArrayList<Renderable>();
this.context = context;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPurgeable = true;
this.backgroundImage = BitmapFactory.decodeResource(
context.getResources(), com.thinkpal.live.R.drawable.aquarium,
options);
this.backgroundImage1 = BitmapFactory.decodeResource(
context.getResources(), com.thinkpal.live.R.drawable.waquarium,
options);
this.boble = BitmapFactory.decodeResource(context.getResources(),
com.thinkpal.live.R.drawable.bubble, options);
this.addFishes();
}
private void addFishes() {
Point startPoint = new Point(100, 100);
this.fishes.add(new ClownFish(this.context, this, startPoint, 90));
Point startPoint1 = new Point(100, 300);
this.fishes.add(new ClownFish(this.context, this, startPoint1, 50));
Point startPoint2 = new Point(200, 200);
this.fishes.add(new ClownFish(this.context, this, startPoint2, 15));
}
private void renderBackGround(Canvas canvas) {
Paint paint = new Paint();
canvas.drawBitmap(this.backgroundImage, 0, 0, null);
if (bgchange) {
canvas.drawBitmap(this.backgroundImage1, 0, 0, null);
}
canvas.drawBitmap(this.boble, x, y, null);
canvas.drawBitmap(this.boble, x1, y1, null);
canvas.drawBitmap(this.boble, x2, y2, null);
canvas.drawText("Think palm", x + 10, y + 45, paint);
canvas.drawText("Cochin", x1 + 20, y1 + 45, paint);
canvas.drawText("Welcome to", x2 + 10, y2 + 45, paint);
}
}
이것에 대해 자세히 설명해 주시겠습니까? WallpaperService에서 getTheme()을 어디에서 호출하고 레이아웃을 추가 할 수 있습니까? FrameLayout을 라이브 배경 화면의 컨텐트로 사용하려고합니다. 감사! – Nick
그것에 관해가는 길은 상황에 따라 달라질 수 있습니다. FrameLayout 소스를 어딘가에 게시 할 수 있습니까? 또한 레이아웃을 적용하여 레이아웃 레이아웃 속성 (layout_width, layout_gravity 등)을 언급했습니다. 혼란 스럽습니다. 손이 필요한지 알고 싶다면 라이브 배경 화면에 접근 할 수있는 방법은 다양하며 불가능한 것은 없습니다. –