Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法在xml中创建一个drawable,它使用图像和一些边距来抵消它?这是为了在无法设置边距的地方添加可绘制对象,即在更改操作栏的“向上”插入符号时。
在 Android 的开发者页面上稍微搜索一下就发现了。您可以创建一个图层列表,其中有一个项目:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:left="[margin in pixels(dp)]" android:drawable="@drawable/side_bar_button"/> </layer-list>
这会将可绘制对象向左偏移您想要的像素数量。这也可以用于右、上和下。