我正在研究谷歌设计准则,但在我的应用程序中实现其中的一些部分时遇到困难。
尺寸:
主要文本字体:Roboto Regular 16sp
次要文本字体:Roboto Regular 14sp
平铺高度:72dp
左侧头像内边距:16dp
文本左侧内边距:72dp
文本上下内边距:20dp
准则规定,具有头像和主/次要文本的列表项应具有20dp的顶部/底部文本内边距,并且视图的高度应为72dp。 如果我按照上面的内容来实现,将会得到以下XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="72dp"
android:background="#FFF">
<TextView
android:id="@+id/primary_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:paddingLeft="72dp"
android:paddingRight="16dp"
android:paddingTop="20dp"
android:singleLine="true"
android:text="Primary text"
android:textSize="16sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/primary_text"
android:fontFamily="sans-serif"
android:paddingBottom="20dp"
android:paddingLeft="72dp"
android:paddingRight="16dp"
android:singleLine="true"
android:text="Secondary text with preview of further content"
android:textSize="14sp" />
</RelativeLayout>
这是在图形布局编辑器中的显示效果:
![graphical layout preview](https://istack.dev59.com/8OZHT.webp)
![real device](https://istack.dev59.com/HYv90.webp)
请注意:“只需将高度增加到X dp,您的问题就解决了”对我来说不是足够的答案,因为指南对这些大小非常具体。