QMUI-Android的一些尝试(圆形进度条、Loading、圆形图片、圆形按钮、椭圆图片)

最近在看腾讯QMUI库,觉得有很多地方可以值得借鉴的……


QMUI-Android的一些尝试(圆形进度条、Loading、圆形图片、圆形按钮、椭圆图片)


布局文件:

<com.qmuiteam.qmui.widget.QMUITopBar
    android:id="@+id/topBar"
    android:layout_width="match_parent"
    android:layout_height="30dp"></com.qmuiteam.qmui.widget.QMUITopBar>


<com.qmuiteam.qmui.widget.QMUILoadingView
    android:id="@+id/loadView"
    android:layout_width="match_parent"
    android:layout_height="50dp"/>

<com.qmuiteam.qmui.widget.QMUIProgressBar
    android:id="@+id/progressBar"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_marginTop="20dp"
    app:qmui_stroke_width="15dp"
    app:qmui_background_color="@color/qmui_config_color_10_pure_black"
    app:qmui_progress_color="@color/qmui_config_color_red"
    android:textDirection="firstStrongLtr"
    app:qmui_type="type_circle"/>

<com.qmuiteam.qmui.widget.QMUIRadiusImageView
    android:id="@+id/iv_image"
    android:layout_width="match_parent"
    android:layout_height="50dp"/>

<com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
    android:id="@+id/btn"
    android:typeface="sans"
    android:text="点我"
    android:textColor="@color/btn_filled_blue_bg_disabled"
    android:layout_width="50dp"
    android:layout_height="50dp"/>

<com.qmuiteam.qmui.widget.QMUITopBarLayout
    android:id="@+id/barLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"></com.qmuiteam.qmui.widget.QMUITopBarLayout>

代码:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    QMUILoadingView loadingView = findViewById(R.id.loadView);
    QMUIProgressBar bar=findViewById(R.id.progressBar);
    QMUIRadiusImageView imageView=findViewById(R.id.iv_image);
    QMUIRoundButton btn=findViewById(R.id.btn);
    QMUITopBar topBar=findViewById(R.id.topBar);
    QMUITopBarLayout barLayout=findViewById(R.id.barLayout);

    loadingView.setVisibility(View.VISIBLE);
    loadingView.setColor(R.color.qmui_config_color_black);
    loadingView.setBackgroundColor(getResources().getColor(R.color.qmui_s_transparent));
    loadingView.setActivated(true);
    loadingView.setSize(100);
    loadingView.start();

    bar.setMaxValue(100);
    bar.setProgress(70);

    imageView.setImageResource(R.drawable.ic_launcher_background);
    imageView.setCircle(true);
    imageView.setCornerRadius(100);
    imageView.setOval(false);//是否椭圆
    imageView.setBorderWidth(10);//设置边缘宽度

   topBar.setTitle("你好");
   topBar.setBackgroundColor(getResources().getColor(R.color.qmui_config_color_10_pure_black));
   topBar.showTitleView(true);
   topBar.addLeftBackImageButton();

   barLayout.setTitle("撒地方");
   barLayout.addLeftTextButton("",R.drawable.ic_launcher_background);

}


先到这里,还有很多好的功能没发掘出来。