androiddialog动画
㈠ 安卓开发中:把Activity设置为dialog模式后,无法控制消失动画的问题!
不知道你是怎么设置的消失动画,即使设置了Dialog的Theme 他本质上还是Activity的,应该设置Activity切换动画overridePendingTransition(R.anim.alpha_appear,R.anim.alpha_disappear);
㈡ 如何自定义Android Dialog的样式
Android 中自定义Dialog的样式,主要是通过自定义的xml,然后加载到dialog的背景中,如下步骤:
1、自定义Dialog
java">finalDialogdialog=newDialog(this,R.style.Theme_dialog);
2、窗口布局
ViewcontentView=LayoutInflater.from(this).inflate(R.layout.select_list_dialog,null);
3、把设定好的窗口布局放到dialog中
dialog.setContentView(contentView);
4、设定点击窗口空白处取消会话
dialog.setCanceledOnTouchOutside(true);
5、具体的操作
ListViewmsgView=(ListView)contentView.findViewById(R.id.listview_flow_list);
6、展示窗口
dialog.show();
例:
finalDialogdialog=newDialog(this,R.style.Theme_dialog);
ViewcontentView=LayoutInflater.from(this).inflate(R.layout.select_list_dialog,null);
dialog.setContentView(contentView);
dialog.setCanceledOnTouchOutside(true);
ListViewmsgView=(ListView)contentView.findViewById(R.id.listview_flow_list);
TextViewtitleText=(TextView)contentView.findViewById(R.id.title);
titleText.setText("请选择银行卡");
=(this,mBankcardList);
msgView.setAdapter(adapter);
msgView.setOnItemClickListener(newOnItemClickListener(){
@Override
publicvoidonItemClick(AdapterViewparent,Viewview,intposition,longid){
//Toast.makeText(RechargeFlowToMobileActivity.this,
//position+"",0).show();
mSelectCard=mBankcardList.get(position);
Stringarea=mSelectCard.getBank_card();
mCardNumberText.setText(area);
dialog.dismiss();
}
});
ButtoncloseBtn=(Button)contentView.findViewById(R.id.close);
closeBtn.setClickable(true);
closeBtn.setOnClickListener(newView.OnClickListener(){
@Override
publicvoidonClick(Viewv){
dialog.dismiss();
}
});
dialog.show();
以上就是在Android开发自定义dialog样式的方法和步骤,android很多的控件都提供了接口或者方法进行样式的定义和修改。
㈢ Android Dialog动画效果无效
Window w= dialog.getWindow();
w.setWindowAnimations(R.style.PopupAnimation);
dialog.show();
你的代码完全没有问题,莫非和API版本有关?我在API 14上一切正常。
㈣ Android Dialog如何显示在空间的下面
Android中Alertdialog是没有直接显示在指定控件下的API的,你可以使用PopupWindow来实现显示在指定控件下面的需求。PopupWindow不仅能显示在指定位置,还可以指定显示和消失的动画,不必限定死必须用哪个控件,只需要实现需求即可。
PopupWindow 是一个可以显示在当前 Activity 之上的浮动容器,PopupWindow 弹出的位置是能够改变的,按照有无偏移量,可以分为无偏移和有偏移两种;按照参照对象的不同又可以分为两种:相对某个控件(Anchor 锚点)的位置和在父容器内部的相对位置。
LayoutInflatermLayoutInflater=(LayoutInflater)context.getSystemService(LAYOUT_INFLATER_SERVICE);
ViewcontentView=mLayoutInflater.inflate(R.layout.pop,null)
//R.layout.pop为PopupWindow的布局文件
PopupWindowpop=newPopupWindow(contentView,LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
pop.setBackgroundDrawable(newBitmapDrawable());
//指定PopupWindow的背景
pop.setFocusable(true);
//指定PopupWindow显示在你指定的view下
pop.showAsDropDown(your_view);
㈤ 开发者选项窗口动画和过渡动画区别
窗口动画和过渡动画是指在窗口(activity或dialog)切换时的显示动画,窗口动画的范围相对较广,包括activity和dialog,而过渡动画只包括activity。
? 第一种方法是调用overridePendingTransition的方法,记得要在startActivity之前调用,还可以用startActivity(Intent, Bundle)设置Bundle来实现,这种可以跨Context,而overridePendingTransition只能在当前app内实现,具体做法是ActivityOptions.makeCustomAnimation(context, enterResId, exitResId).toBundle(),这种方法要求系统是4.1以后的。这两种方法实现的都是过渡动画。
? 前面这些方法都只能做activity的动画,要做dialog的动画,就必须用窗口动画。方法是设置style,然后dialog.getWindow().setWindowAnimations(R.style.MyStyle)或者dialog.getWindow().getAttributes().windowAnimations = R.style.MyStyle;这样就可以在弹出dialog的时候播放动画了。窗口动画也可以作用在activity上,style的设置一样,代码也差不多,直接在activity内就可以调用getWindow这条方法。style还有另外一种做法:
? 这种设置的是过渡动画,只对activity有用,对dialog没用。(除了用getWindow来设置动画资源外,还可以在你的Theme里添加一个item,item的name是android:windowAnimationStyle,然后指定上面的一种style)。
? 从原理上看,窗口动画和过渡动画其实就是系统在切换窗口时读取相应的动画资源,上面的所有做法本质上就是在替换那些资源。开发者需要处理的是如何选择,是窗口动画还是过渡动画。如果是dialog,只有窗口动画可选,也只能通过style来完成。如果是activity,就两种动画都可以,但大多情况下还是用过渡动画,因为通过像overridePendingTransition这些api可以很简单的实现,而如果想把动画应用到整个Activity,用style就更方便,至于用上面哪种style,其实没什么影响。
? 在实际的开发中,其实并不提倡用上面这些方法,因为手机的设置可以关闭这两种动画(在开发者选项那里),你没法保证app一定能显示动画。对于activity动画来说,可以在新的activity初始化结束后启动常规的动画,但这种方法要求你必须等到窗口的相关view初始化结束,但什么时候结束是无法预测的,这和手机性能有关,所以你可以设置定时器来播放,而对于dialog就没有其他解决的方法了。
㈥ android 使用activity 当dialog弹出框 ,layout出现左右两边有间距
WindowManager windowManager = getWindowManager();
Display display = windowManager.getDefaultDisplay();
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.MATCH_PARENT;
getWindow().setAttributes(lp);
㈦ 怎么用Android实现ActionSheet效果
需要在项目中使用到类似iOS ActionSheet的动画效果,在查阅了一些资料后,顺利实现了,在这里把方法分享给大家。
1、首先在res/anim文件夹下创建slide_up.xml和slide_down.xml(文件名随意),代码如下:
3.最后,在dialog弹出之前,使用刚刚实现的动画效果:
dialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation;
㈧ Android操作系统中默认的loading动画怎么调用
progressdialog先添加要加载xml面
始隐藏其组件
显示progressdialog
延迟段间再显示其组件隐藏progressdialog
// 图片数量
private int count =8;
//图片ID数组
private int[] ids={R.drawable.r1,R.drawable.r2,R.drawable.r3,R.drawable.r4,
R.drawable.r5,R.drawable.r6,R.drawable.r7,R.drawable.r8};
private Handler handler;
private ImageView img_loading;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.loading);
img_loading = (ImageView) this.findViewById(R.id.img_loading);
handler = new Handler(){
public void handleMessage(Message msg)
{
/**
* 更改ImageView图片
*/
img_loading.setImageDrawable(getDrawable(msg.what));
}
};
play();
}
/**
* 获取图片象
* @param id
* @return
*/
private Drawable getDrawable(int id)
{
return this.getResources().getDrawable(ids[id]);
}
/**
* 播放画
*/
private void play()
{
new Thread(){
@SuppressWarnings("static-access")
@Override
public void run()
{
while(true)
{
for (int i = 0; i < count; i++)
{
handler.sendEmptyMessage(i);
try
{
this.sleep(100);
} catch (InterruptedException e)
{
e.printStackTrace();
}
}
}
}
}.start();
}
㈨ 关于android中Dialog显示动画的问题,求教
可以用popupWindow来实现 popupWindow.setFocusable(true); popupWindow.setAnimationStyle(android.R.style.Animation_Dialog); popupWindow.setBackgroundDrawable(new BitmapDrawable()); popupWindow.setOutsideTouchable(true); 加上这几句话就可以了 ,跟dialog有相同的效果 Dialog也可以实现,但是我没有研究,你可以试试,有了答案告诉一下,
㈩ android 旋转 dialog会自动旋转吗
android源代码之Rotate旋转动画 标签为旋转节点 Tween一共为我们提供了3种动画渲染模式。 android:interpolator="@android:anim/accelerate_interpolator" 设置动画渲染器为加速动画(动画播放中越来越快) android:interpolator="@android:anim/decelerate_interpolator" 设置动画渲染器为减速动画(动画播放中越来越慢) android:interpolator="@android:anim/accelerate_decelerate_interpolator" 设置动画渲染器为先加速在减速(开始速度最快 逐渐减慢) 如果不写的话 默认为匀速运动 android:fromDegrees="+360"设置动画开始的角度 android:toDegrees="0"设置动画结束的角度 这个动画布局设置动画将向左做360度旋转加速运动。 android:interpolator="@android:anim/accelerate_interpolator" android:fromDegrees="+360" android:toDegrees="0" android:pivotX="50%" android:pivotY="50%" android:ration="2000" /> 复制代码 代码实现 import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.Button; import android.widget.ImageView; public class RotateActivity extends Activity { /**向左旋转动画按钮**/ Button mButton0 = null; /**向右旋转动画按钮**/ Button mButton1 = null; /**显示动画的ImageView**/ ImageView mImageView = null; /**向左旋转动画**/ Animation mLeftAnimation = null; /**向右旋转动画**/ Animation mRightAnimation = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.retate); /**拿到ImageView对象**/ mImageView = (ImageView)findViewById(R.id.imageView); /**加载向左与向右旋转动画**/ mLeftAnimation = AnimationUtils.loadAnimation(this, R.anim.retateleft); mRightAnimation = AnimationUtils.loadAnimation(this, R.anim.retateright); mButton0 = (Button)findViewById(R.id.button0); mButton0.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { /**播放向左旋转动画**/ mImageView.startAnimation(mLeftAnimation); } }); mButton1 = (Button)findViewById(R.id.button1); mButton1.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { /**播放向右旋转动画**/ mImageView.startAnimation(mRightAnimation); } }); } }