我希望有一种方法可以在 xml
中的一行中指定所有四个边的填充或边距。就像我们在 css
中所做的那样.
例如在 css 中:padding: 1px 2px 3px 4px;
我们有这样的事情吗?
最佳答案
Android O DP1 为 padding 和 layout_margin 引入了定向 XML 属性。请注意,它们优先于特定于边缘的值。
<TextView
android:id="@+id/txtContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TEXT"
android:textSize="14sp"
android:layout_marginHorizontal="@dimen/spacing_medium" android:layout_marginVertical="@dimen/spacing_large"
/>
关于android - XML 在一行中为所有边声明填充或边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48457158/