2013-09-21 48 views
5

Tôi tự hỏi làm thế nào tôi có thể làm như sau. Tôi muốn nền ứng dụng của mình hoạt hình (giả sử chim bay loại giấy tường sống như thế nào). Được này thường được thực hiện sử dụng nền GIF hay tôi cần phải mã hóa hình ảnh động hoặc sử dụng sơn/vẽ chức năng để vẽ hình ảnh động (Tôi hy vọng là không!)Hình ảnh hoạt hình nền

Bất kỳ con trỏ được đánh giá là tôi không chắc chắn làm thế nào để làm điều đó

Cảm ơn bạn

+0

Liệu nó giúp bạn? http://mobile.tutsplus.com/tutorials/android/creating-live-wallpapers-on-android/ – RobinHood

+0

Cảm ơn nhưng bài nói chuyện này về cách tạo giấy dán tường. Tôi quan tâm hơn đến cách những hình nền động này được thực hiện ngay từ đầu. Vẽ của chúng tôi một con chim lập trình? Hoặc sử dụng hình ảnh hoặc sử dụng GIF hoặc có thể là một công cụ vẽ đặc biệt? – Snake

+0

Bạn định kế hoạch clip của mình trong bao lâu? Và nó có phải là toàn màn hình hay chỉ là một phần của nó hoạt hình? – pumpkee

Trả lời

8

bạn có thể làm điều đó bằng cách sử dụng GIF hình ảnh cũng có, nhưng trước tiên chuyển đổi đó GIF để khung

trong xml

<ImageView 
    android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:id="@+id/img1" 
/> 

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignTop="@+id/img1" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="156dp" 
    android:text="submit" 
    /> 

trong java

public class MainActivity extends Activity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    ImageView i = (ImageView)findViewById(R.id.img1); 
    i.setBackgroundResource(R.drawable.gif); 

    AnimationDrawable pro = (AnimationDrawable)i.getBackground(); 
    pro.start(); 
} 
} 

trong drawable tạo file hình ảnh động

<?xml version="1.0" encoding="utf-8"?> 
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/selected" android:oneshot="false"> 
    <item android:drawable="@drawable/frame0" android:duration="50" /> 
    <item android:drawable="@drawable/frame1" android:duration="50" /> 
    <item android:drawable="@drawable/frame2" android:duration="50" /> 
    <item android:drawable="@drawable/frame3" android:duration="50" /> 
    <item android:drawable="@drawable/frame4" android:duration="50" /> 
    <item android:drawable="@drawable/frame5" android:duration="50" /> 
    <item android:drawable="@drawable/frame6" android:duration="50" /> 
    <item android:drawable="@drawable/frame7" android:duration="50" /> 
    <item android:drawable="@drawable/frame8" android:duration="50" /> 
    <item android:drawable="@drawable/frame8" android:duration="50" /> 
    <item android:drawable="@drawable/frame9" android:duration="50" /> 
    <item android:drawable="@drawable/frame10" android:duration="50" /> 

</animation-list> 

Hy vọng điều này có thể giúp bạn

+0

bạn có hình ảnh của bạn trong thư mục drawable và tệp hình ảnh động gif trong drawable – vish

+0

Đây phải là câu trả lời được chọn! – Jonny2Plates

Các vấn đề liên quan