Android类似于带文本的进度条的效果怎么实现
展开全部
可以加载一个自定义的loading_process_dialog_anim
调用的方法:
[mw_shl_code=java,false]
public void showRoundProcessDialog(Context mContext, int layout)
{
OnKeyListener keyListener = new OnKeyListener()
{
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_HOME || keyCode == KeyEvent.KEYCODE_SEARCH)
{
return true;
}
return false;
}
};
mDialog = new AlertDialog.Builder(mContext).create();
mDialog.setOnKeyListener(keyListener);
mDialog.show();
// 注意此处要放在show之后 否则会报异常
mDialog.setContentView(layout);
}[/mw_shl_code]
XML:
[mw_shl_code=java,false]<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<ProgressBar
android:id="@+id/loading_process_dialog_progressBar"
android:layout_width="33dp"
android:layout_height="wrap_content"
android:indeterminate="false"
android:indeterminateDrawable="@anim/loading" />
</LinearLayout>[/mw_shl_code]
loading.xml:
[mw_shl_code=java,false]<?xml version="1.0" encoding="utf-8"?>
<animation-list android:oneshot="false"
xmlns:android="">
<item android:duration="250" android:drawable="@drawable/loading_01" />
<item android:duration="250" android:drawable="@drawable/loading_02" />
<item android:duration="250" android:drawable="@drawable/loading_03" />
<item android:duration="250" android:drawable="@drawable/loading_04" />
<item android:duration="250" android:drawable="@drawable/loading_05" />
<item android:duration="250" android:drawable="@drawable/loading_06" />
<item android:duration="250" android:drawable="@drawable/loading_07" />
</animation-list> [/mw_shl_code]
调用的方法:
[mw_shl_code=java,false]
public void showRoundProcessDialog(Context mContext, int layout)
{
OnKeyListener keyListener = new OnKeyListener()
{
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_HOME || keyCode == KeyEvent.KEYCODE_SEARCH)
{
return true;
}
return false;
}
};
mDialog = new AlertDialog.Builder(mContext).create();
mDialog.setOnKeyListener(keyListener);
mDialog.show();
// 注意此处要放在show之后 否则会报异常
mDialog.setContentView(layout);
}[/mw_shl_code]
XML:
[mw_shl_code=java,false]<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<ProgressBar
android:id="@+id/loading_process_dialog_progressBar"
android:layout_width="33dp"
android:layout_height="wrap_content"
android:indeterminate="false"
android:indeterminateDrawable="@anim/loading" />
</LinearLayout>[/mw_shl_code]
loading.xml:
[mw_shl_code=java,false]<?xml version="1.0" encoding="utf-8"?>
<animation-list android:oneshot="false"
xmlns:android="">
<item android:duration="250" android:drawable="@drawable/loading_01" />
<item android:duration="250" android:drawable="@drawable/loading_02" />
<item android:duration="250" android:drawable="@drawable/loading_03" />
<item android:duration="250" android:drawable="@drawable/loading_04" />
<item android:duration="250" android:drawable="@drawable/loading_05" />
<item android:duration="250" android:drawable="@drawable/loading_06" />
<item android:duration="250" android:drawable="@drawable/loading_07" />
</animation-list> [/mw_shl_code]
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询