Android 使用Textview作为分隔符而不是View是一种好的做法吗

Android 使用Textview作为分隔符而不是View是一种好的做法吗,android,android-layout,view,textview,android-view,Android,Android Layout,View,Textview,Android View,使用TextView作为分隔符而不是View是否是一种好的做法。如果没有,为什么??在下图中,我使用了TextView(即第1行)和View(即第2行),但看起来是一样的。我参考了很多网站,但仍然没有得到任何好的解释。以下是TextView和View TextView <TextView android:id="@+id/TextView" android:layout_width="match_parent" android:layout_height="1dp

使用
TextView
作为分隔符而不是
View
是否是一种好的做法。如果没有,为什么??在下图中,我使用了
TextView
(即第1行)和
View
(即第2行),但看起来是一样的。我参考了很多网站,但仍然没有得到任何好的解释。以下是
TextView
View

TextView

<TextView
    android:id="@+id/TextView"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="@android:color/darker_gray"
    android:layout_below="@+id/line1"/>
<View
    android:id="@+id/View"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="@android:color/darker_gray"
    android:layout_below="@+id/line2"/>

查看

<TextView
    android:id="@+id/TextView"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="@android:color/darker_gray"
    android:layout_below="@+id/line1"/>
<View
    android:id="@+id/View"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="@android:color/darker_gray"
    android:layout_below="@+id/line2"/>

据我所知,
视图
只是为特殊类型的设计而发明的,如
分隔器
给边框
定型。或者一些创造特殊效果


但是
TextView
的设计就是在上面写
Text
。因此,要创建
分隔器
分隔器
,视图是更好的选择。

如果您仅为分隔器使用
文本视图
。这会浪费一些记忆。因为
TextView
将在Init中分配或
新对象()
,而
onMeasure()
onDraw()
将花费更多时间。因此,您只需使用
View
作为分隔符。

如果查看TextView类的代码,您将看到它扩展了View。换句话说,视图类拥有的所有内容都存在于TextView类中,以及一系列其他方法、属性等。如果您使用文本视图作为分隔符,您将在布局中添加比实际需要的更复杂的对象。这将降低应用程序的性能,并且可能会在将来引入错误。因此,不要将TextView用作分隔符。这绝对适合仅用于一个视图。

否。将视图用于单独的视图。ExtView也是一个视图阅读问题@Divyesh。我问过,如果答案是否定的,那么解释一下为什么textview有自己的方法和自定义,而View有简单的方法。你可以检查他们的代码。因此,我认为“视图”是更好的选择。