国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 系統(tǒng) > Android > 正文

詳解Android開(kāi)發(fā)之圖形圖像與動(dòng)畫

2020-02-21 17:30:29
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

在android開(kāi)發(fā)中,編碼人員要考慮到每個(gè)模塊的構(gòu)建和維護(hù),當(dāng)然動(dòng)畫制作作為編碼人員的作品,下面是武林技術(shù)頻道為大家介紹的詳解Android開(kāi)發(fā)之圖形圖像與動(dòng)畫,一起來(lái)看看吧!

首先需要先介紹下LayoutAnimationController:

?* 1.LayoutAnimationController用于為一個(gè)layout里面的控件,或者是一個(gè)ViewGroup
?* 里面的控件設(shè)置動(dòng)畫效果(即整個(gè)布局)
?* 2.每一個(gè)控件都有相同的動(dòng)畫效果
?* 3.這些控件的動(dòng)畫效果在不同的實(shí)現(xiàn)顯示出來(lái)
?* 4.LayoutAnimationController可以在xml文件當(dāng)中設(shè)置,也可以在代碼中進(jìn)行設(shè)置

本文就針對(duì)兩種實(shí)現(xiàn)LayoutAnimationController的方法分別進(jìn)行介紹:

一,在XML文件中實(shí)現(xiàn)

步驟如下圖所示:



?下面以一個(gè)實(shí)例來(lái)說(shuō)明實(shí)現(xiàn)的方法

實(shí)現(xiàn)的例子是點(diǎn)擊“測(cè)試”按鈕,有動(dòng)畫形式的view展現(xiàn)出來(lái),截圖如下:

具體的實(shí)現(xiàn)過(guò)程如下

需要兩個(gè)動(dòng)畫xml文件:

1.list_item_layout

?

<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:animation="@anim/list_item_alpha"
android:animationOrder="normal"
android:delay="0.8" />


2.list_item_alpha

?

?

?


<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="2000"
/>
</set>


3.需要在listview中添加如下的說(shuō)明

?

?

?


android:layoutAnimation="@anim/list_item_layout"


具體的實(shí)現(xiàn)代碼如下:

?

?

?


public class LayoutAnimation_Activity extends Activity {
private Button button;
private Button button2;
private ListView listView;
private static final String[] STRINGS={"BruceZhang","Alhpa","Translate","Blanklin","Rotate",
"GreenFrank"};

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_layout_animation_);
button=(Button)findViewById(R.id.button);
button2=(Button)findViewById(R.id.button2);
listView=(ListView)findViewById(R.id.listview);
final ArrayAdapter<String> adapter=new ArrayAdapter<String>(this, R.layout.item_list, STRINGS);
button.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
listView.setAdapter(adapter);
}
});
button2.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
listView.setAdapter(null);
}
});
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_layout_animation_, menu);
return true;
}

}


二,在java代碼中實(shí)現(xiàn)LayoutAnimationController

?

實(shí)現(xiàn)的步驟如下圖:

在本例中用到的代碼如下

?

Animation animation=AnimationUtils.loadAnimation(LayoutAnimation_Activity.this,
R.anim.list_item_alpha);
LayoutAnimationController laController=new LayoutAnimationController(animation);
laController.setOrder(LayoutAnimationController.ORDER_NORMAL);
listView.setLayoutAnimation(laController);

上文是詳解Android開(kāi)發(fā)之圖形圖像與動(dòng)畫的介紹,武林技術(shù)頻道小編為大家做了簡(jiǎn)單的介紹。其實(shí)不管學(xué)習(xí)什么都要努力,努力后肯定有收獲。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 苍南县| 怀柔区| 平阳县| 邢台县| 时尚| 清远市| 射洪县| 府谷县| 扎兰屯市| 铅山县| 金川县| 古田县| 连城县| 泸水县| 双城市| 乌鲁木齐市| 绥棱县| 苗栗市| 岳西县| 犍为县| 滨海县| 苍梧县| 芒康县| 山阳县| 于田县| 呼图壁县| 建水县| 罗甸县| 比如县| 卫辉市| 金乡县| 龙游县| 鲁山县| 塔河县| 华蓥市| 科技| 宁陕县| 嵩明县| 白朗县| 荆门市| 剑河县|