1. 程式人生 > >QMUI-Android的一些嘗試(圓形進度條、Loading、圓形圖片、圓形按鈕、橢圓圖片)

QMUI-Android的一些嘗試(圓形進度條、Loading、圓形圖片、圓形按鈕、橢圓圖片)

最近在看騰訊QMUI庫,覺得有很多地方可以值得借鑑的……

佈局檔案:

<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);

}

先到這裡,還有很多好的功能沒發掘出來。