根据Android Material Design Guide

时间:2016-04-10 13:43:56

标签: android android-layout

我正在尝试根据Google Material Design规范创建一个带有标题的分隔符,但我无法使其工作。谷歌为什么推出一个甚至在支持或目标平台级别都无法提供的规范?所以我在这里重新创建材料规范以使用旧版本,这是我到目前为止所得到的:

    <TextView
        android:id="@+id/textview_task_header1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="42dp"
        android:layout_marginBottom="12dp"
        android:drawableTop="@drawable/drawable_separator"
        android:textSize="16sp"
        android:textStyle="bold"
        android:textColor="#bfbfbf"
        android:text="Location"/>

我想创建一个标题,某种分隔符。我不想使用列表因为列表需要我创建一个我认为在我的案例中真的不切实际的适配器。我必须使用XML布局UI,但我无法弄明白。

我需要看起来像这样的东西,我需要一个没有行分隔符的标题和一个带有一个分隔符的标题:

enter image description here

此外,我能够通过TextView创建标题并设置上下边距。问题是我无法在我的案例中显示可绘制的线条,我不觉得我在这里做正确的事情。它太乱了。

如果您没有发布表明使用hackish解决方案的答案,我将不胜感激。出于某种原因,我不想走这条路。 :/

1 个答案:

答案 0 :(得分:1)

<View
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="@android:color/darker_gray"/>

要添加垂直分隔符,请切换layout_widthlayout_height