天天看點

Android LinearLayout horizontal 添加分割線不顯示 解決方案

Android LinearLayout horizontal 添加分割線不顯示 解決方案

Android 踩過的那些坑 ,我們在設定LinearLayout 分割線時 發現android:orientation="horizontal"時 分割線顯示不出來 

原因就是shape檔案屬性的問題

不顯示的shape 檔案寫法是:

<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <solid android:color="@color/fengexian" />

    <size android:height="1px"/>

</shape>

正确的寫法:

<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <solid android:color="@color/fengexian" />

    <size android:height="1px" android:width="1px" />

</shape>