shape畫圖底部邊框出不來的解決方法

今天碰到的一個問題:

用shape畫了兩個框框如下:

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle">
    
    <size android:width="60dp"
        android:height="19dp"/>
    <corners android:radius="9.5dp"/>
    <solid android:color="#ffffff"/>
    <stroke android:width="1dp"
        android:color="#59AB0C"/>

</shape>

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle">
    
    <size android:width="60dp"
        android:height="19dp"/>
    <corners android:radius="9.5dp"/>
    <solid android:color="#ffffff"/>
    <stroke android:width="1dp"
        android:color="#6E6E6E"/>

</shape>

把它當作這邊的背景:
<TextView
                    android:id="@+id/headview_allgone"
                    android:layout_width="60dp"
                    android:layout_height="19dp"
                    android:background="@drawable/circular_black"
                    android:clickable="true"
                    android:gravity="center"
                    android:text="我知道了"
                    android:textColor="#6E6E6E"
                    android:textSize="12sp" />

<TextView
                    android:id="@+id/headview_allupdata"
                    android:layout_width="60dp"
                    android:layout_height="19dp"
                    android:layout_marginRight="5dp"
                    android:background="@drawable/circular_green"
                    android:gravity="center"
                    android:text="一鍵更新"
                    android:textColor="#59AB0C"
                    android:textSize="12sp" />
結果問題出來了:


框框的底部沒有了

找了好久才發現,是因爲邊框也有寬度,在shape那邊有20dp,而這邊的高只設置了19dp,所以底部沒出來

最後把高改成match_parent就ok啦,雖然只是小小的細節問題,但往往是細節發的最多時間,所以細心很重要

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章