我想做一個新的佈局頁面,我想放兩個按鈕,並在上面的每個按鈕,我需要給幀動畫。所以加載按鈕看起來像泡泡內。以下是我使用來實現這個代碼:動畫和佈局問題與我的新應用程序?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background_full">
<Button android:id="@+id/btnMusic"
android:layout_width="80dp"
android:layout_height="80dp"
android:gravity="center"
android:layout_marginLeft="215dp"
android:layout_marginTop="140dp"
android:background="@drawable/icon"/>
<ImageView android:id="@+id/imgMusic"
android:layout_width="150dp"
android:layout_height="150dp"
android:gravity="center"
android:layout_marginLeft="170dp"
android:layout_marginTop="100dp"
android:background="@drawable/button_background"/>
<Button android:id="@+id/btnMovies"
android:layout_width="80dp"
android:layout_height="80dp"
android:gravity="center"
android:layout_marginLeft="405dp"
android:layout_marginTop="140dp"
android:background="@drawable/icon1"/>
<ImageView android:id="@+id/imgMovies"
android:layout_width="150dp"
android:layout_height="150dp"
android:gravity="center"
android:layout_marginLeft="360dp"
android:layout_marginTop="100dp"
android:background="@drawable/button_background"/>
</RelativeLayout>
我JAV代碼是這樣的:
public class BubbleActivity extends Activity {
/** Called when the activity is first created. */
/** Called when the activity is first created. */
Button btnMusic, btnMovies ;
ImageView imgMusic,imgMovies;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
btnMusic = (Button)findViewById(R.id.btnMusic);
btnMovies = (Button)findViewById(R.id.btnMovies);
btnMusic.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
Intent intent = new Intent(PixieActivity.this,Splash.class);
startActivity(intent);
}
});
ImageView imgMusic = (ImageView)findViewById(R.id.imgMusic);
imgMusic.setBackgroundResource(R.drawable.frame_animation);
AnimationDrawable frameAnimation =(AnimationDrawable) imgMusic.getBackground();
if (frameAnimation.isRunning()) {
frameAnimation.stop();
}
else {
frameAnimation.start();
}
ImageView imgMovies = (ImageView)findViewById(R.id.imgMovies);
imgMovies.setBackgroundResource(R.drawable.frame_animation);
AnimationDrawable frameAnimation1 =(AnimationDrawable) imgMovies.getBackground();
if (frameAnimation1.isRunning()) {
frameAnimation1.stop();
}
else {
frameAnimation1.start();
}
}}
但由於按鍵佈局成爲不同分辨率的手機分心的利潤。有沒有其他方法可以實現與設備分辨率無關的相同佈局。另外我想將泡泡動畫添加到我將在下一頁中製作的每個圖標中。請幫忙。