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

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>


 

原文地址:https://www.cnblogs.com/pangblog/p/3310538.html