andriod 如何設計圓形頭像

如何設計圓形頭像

  1. 很多時候,我們需要設計類似於頭像一樣的部分,但是這部分很多時候都是用圓形頭像,本篇博客就是討論如何設計圓形頭像

效果圖

效果圖

實現代碼

  1. 利用widget下的cardview和imageview實現。
  2. 整體分爲兩個部分,先劃分總體佈局和圓形區域;接着在圓形區域插入目標圖片。
  3. 注意imageview部分,width和height一定是match_parent,因爲是在第一步劃分的圓形區域顯示的。
<android.support.v7.widget.CardView
            android:id="@+id/cv_user_head"
            android:layout_width="60dp"
            android:layout_height="60dp"
            app:cardCornerRadius="45dp"
            app:cardElevation="10dp"
            android:layout_marginTop="5dp"
            android:layout_marginLeft="220dp"
            app:cardPreventCornerOverlap="true"
            >
            <ImageView
                android:id="@+id/tv_user_head"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:src="@drawable/head"
                android:scaleType="centerCrop"/>
        </android.support.v7.widget.CardView>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章