我想在一個activity中向下滑動android中的Relative佈局。 我有以下功能滑下佈局:在android中引用ViewGroup
public void setLayoutAnim_slidedown(ViewGroup panel, Context ctx) {
AnimationSet set = new AnimationSet(true);
Animation animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
0.0f, Animation.RELATIVE_TO_SELF, -1.0f,
Animation.RELATIVE_TO_SELF, 0.0f);
animation.setDuration(800);
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
// MapContacts.this.mapviewgroup.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
}
});
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(
set, 0.25f);
panel.setLayoutAnimation(controller);
}
當你看到第一行中的一個參數的類型的ViewGroup ..My問題是我怎麼能引用視圖組...
注意我試過以下
LayoutInflater inflater = (LayoutInflater) myContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.childView, null);
但是,這返回查看不是groupView!
可以隨時查看類型轉換到一個ViewGroup作爲一個ViewGroup是超一流的。 – 2012-04-26 09:16:46
另一個問題...我是否必須做比調用函數更多的東西......因爲動畫不是以這種方式開始的......有什麼遺漏嗎? – Developer 2012-04-26 09:32:24