您的位置:首页 > 移动开发 > Android开发

Android改变系统自带环形ProgressBar的大小

2013-09-09 19:29 190 查看
MainActivity如下:

package cc.testprogressbar;

import android.os.Bundle;
import android.app.Activity;
/**
* Demo描述:
* 改变系统自带环形ProgressBar的大小
*
* 改变方式:
* 为ProgressBar设置一个style即可
* 参见styles.xml
*
*/
public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}


main.xml如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="改变系统自带ProgressBar的大小"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dip"
/>

<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
style="@style/testProgressBarStyle"
/>

</RelativeLayout>


styles.xml如下:

<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppBaseTheme" parent="android:Theme.Light">
</style>

<style name="AppTheme" parent="AppBaseTheme">
</style>

<style name="testProgressBarStyle" parent="@android:style/Widget.ProgressBar.Large">
<item name="android:minHeight">50dip</item>
<item name="android:minWidth">50dip</item>
<item name="android:maxHeight">50dip</item>
<item name="android:maxWidth">50dip</item>
</style>

</resources>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: