可绘制图层列表中的动画项目

时间:2016-01-02 04:32:59

标签: android android-activity android-animation drawable layer-list

给出这样的抽象:

def start_def():
    global main
    main.destroy()  

    def run():
        global energy
        energy = energy - 25
        print(energy)

    game = Tk()
    game.title("Anne: O Jogo")
    game.geometry("800x600")
    game.resizable(0,0)

    global energy
    energy = int(100)

    global img
    img = ImageTk.PhotoImage(Image.open("anne.jpg"))
    panel = Label(game, image=img)
    panel.pack(side="left", pady=5, padx=5)
    panel.place(x=15, y=15)

    Label(game, text="Anne", font=("Verdana", 25, "bold")).place(x=220, y=20)
    Label(game, text="Energia: ", font=("Verdana", 15, "bold")).place(x=220, y=70)
    Label(game, text=energy, font=("Verdana", 15, "bold")).place(x=320, y=71)

    b = Button(game, text="Correr", command=run).pack()

我想创建一个动画制作动画颜色动画,但我似乎无法找到一种方法来访问图层列表中的属性。

1 个答案:

答案 0 :(得分:1)

我想出了如何做到这一点:

ImageView iv = (ImageView) findViewById(<id of the layer-list drawable>);
LayerDrawable layer = (LayerDrawable) iv.getDrawable();
GradientDrawable border = (GradientDrawable) layer.getDrawable(0);