haniiii
جمعه 11 بهمن 1392, 14:52 عصر
سلام دوستان
بنده یه مشکل در زمینه انیمیشن ها و view ها دارم ... ممنون میشم کمک کنید
فرض کنید قراره در برنامه با زدن دکمه show/hide که در ابتدای صفحه تعبیه شده ویو مورد نظر ( در اینجا از نوع relativelayout ) ... با توجه به دکمه مربوطه show/hide بشه
این ویو قراره با یه translateAnimation به صورت slide up و slide down نشون داده بشه
( ویو از قبل به صورت Gone در xml در نظر گرفته شده )
این کد فقط ویو مورد نظر (Myview ) رو Translate میکنه و بقیه ویو های پایین اون ثابت باقی میمونن ... حالت ایده ال این هست که بقیه ویو ها هم متناسب تغییرمکان بدن
animation1 = 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
);
animation1.setDuration(600);
animation2 = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f
);
animation2.setDuration(600);
animation2.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
MyView.setVisibility(View.GONE);
}
});
MyView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(tNumber == 0)
{
tNumber = 1;
MyView.startAnimation(animation1);
MyView.setVisibility(View.VISIBLE);
}
else
{
tNumber = 0;
MyView.startAnimation(animation2);
}
}
});
ممنون
بنده یه مشکل در زمینه انیمیشن ها و view ها دارم ... ممنون میشم کمک کنید
فرض کنید قراره در برنامه با زدن دکمه show/hide که در ابتدای صفحه تعبیه شده ویو مورد نظر ( در اینجا از نوع relativelayout ) ... با توجه به دکمه مربوطه show/hide بشه
این ویو قراره با یه translateAnimation به صورت slide up و slide down نشون داده بشه
( ویو از قبل به صورت Gone در xml در نظر گرفته شده )
این کد فقط ویو مورد نظر (Myview ) رو Translate میکنه و بقیه ویو های پایین اون ثابت باقی میمونن ... حالت ایده ال این هست که بقیه ویو ها هم متناسب تغییرمکان بدن
animation1 = 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
);
animation1.setDuration(600);
animation2 = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f
);
animation2.setDuration(600);
animation2.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
MyView.setVisibility(View.GONE);
}
});
MyView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(tNumber == 0)
{
tNumber = 1;
MyView.startAnimation(animation1);
MyView.setVisibility(View.VISIBLE);
}
else
{
tNumber = 0;
MyView.startAnimation(animation2);
}
}
});
ممنون