của Android Tôi không hiểu cách danh sách lớp hoạt động. Tôi đọc chính thức documentation with some examples nhưng nó không làm việc cho tôi như mong đợi. Tôi muốn bốn ô vuông nên được đệm với 1dp, nhưng không có gì giống như mong đợi. Đây là một ảnh chụp màn hình theo tỷ lệ 500%:Tìm hiểu về số điện thoại <layer-list>
(Những màu sắc sai không quan trọng)
Như bạn có thể thấy kích thước là hoàn toàn sai và miếng đệm không bị thiếu. Tôi đã cố gắng đặt các giá trị thực như chiều rộng/chiều cao và phải/trái/đầu/mông để chắc chắn rằng android có được điểm mà tôi muốn.
Đây là xml của tôi:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="0dp" android:left="0dp" android:bottom="0dp" android:right="0dp">
<shape android:shape="rectangle">
<size android:width="9dp"
android:height="9dp"/>
<solid android:color="#f000"/>
</shape>
</item>
<item android:top="1dp" android:left="1dp" android:bottom="5dp" android:right="5dp">
<shape android:shape="rectangle">
<size android:width="3dp"
android:height="3dp"/>
<solid android:color="#f00"/>
</shape>
</item>
<item android:top="1dp" android:left="5dp" android:bottom="5dp" android:right="1dp">
<shape android:shape="rectangle">
<size android:width="3dp"
android:height="3dp"/>
<solid android:color="#0f0"/>
</shape>
</item>
<item android:top="5dp" android:left="1dp" android:bottom="1dp" android:right="5dp">
<shape android:shape="rectangle">
<size android:width="3dp"
android:height="3dp"/>
<solid android:color="#0f0"/>
</shape>
</item>
<item android:top="5dp" android:left="5dp" android:bottom="1dp" android:right="1dp">
<shape android:shape="rectangle">
<size android:width="3dp"
android:height="3dp"/>
<solid android:color="#f00"/>
</shape>
</item>
</layer-list>
Bạn đã thực hiện ảnh chụp màn hình như thế nào? vì hình ảnh nó mang lại cho tôi trông hoàn toàn chính xác ... – OcuS
Tôi lấy trình chỉnh sửa hình ảnh từ nhật thực. – rekire
@rekire Trình chỉnh sửa chỉ lỗi để bạn biết, nó không phải lúc nào cũng hiển thị hình dạng thích hợp. Luôn kiểm tra trên thiết bị. –