【问题标题】:How do I design this UI in android app?如何在 Android 应用程序中设计此 UI?
【发布时间】:2017-01-11 05:44:37
【问题描述】:

我是 android 新手,所以如果这听起来像一个简单的问题,我很抱歉,但我正在尝试在箭头指向的 Text View 上方创建以下行。

这叫View 吗?如果是这样,我该如何放置?我知道这不仅仅是Text View 的边界,因为它不会一直延伸到边缘。

【问题讨论】:

  • 这一行应该是 ListView 分隔线,例如见stackoverflow.com/questions/2372415/…
  • 列表视图分隔符不会显示在第一个元素上方,他必须使用视图
  • 您确定“智能色彩调整”是第一个条目吗?它可以是第二个。这取决于上下文哪种方式是正确的。如果 nicko_yuan 有一个 ListView,使用分隔线将是首选方式。如果没有,则使用视图。

标签: android user-interface


【解决方案1】:

正如你所说,这个元素被命名为View。而我们经常使用的水平线:

<View 
    android:layout_width="match_parent"
    android:layout_height="1dp"/>

这是另一篇讨论您的问题的帖子:divider line

【讨论】:

    【解决方案2】:
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#000"/><!--This will draw a line of 1 dp and black color-->
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="anything you want" />
    
    </LinearLayout>
    

    【讨论】:

      【解决方案3】:
      1. 是的,它的视图
      2. 你可以这样使用。

        <View 
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#e3e3e3"/>
        

      【讨论】:

        【解决方案4】:

        在你的layout 中使用这个而不是Text View

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:background="#818181"
            android:paddingTop="1px"
            android:paddingBottom="1px">
        
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:id="@+id/name"
                android:ellipsize="end"
                android:maxLines="1"
                android:textColor="#ffffff"
                android:text="Text"
                android:background="#ffffff"
                android:gravity="center"/>
        
        </LinearLayout>
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-03-13
          • 1970-01-01
          • 2018-01-13
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多