Android 中未显示视图

View not showing in Android

我有 1px 高的背景视图,可以在视觉上分隔一些线性布局,但其中一个与其他布局没有区别的随机布局没有显示,我无法弄清楚为什么。

  <ScrollView
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:layout_weight="2"
      android:background="#fff">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
      <LinearLayout
          android:orientation="horizontal"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:padding="15dp"
          android:id="@+id/startLoggingButton"
          android:background="@color/background_good">
        <TextView
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="START LOGGING"
            android:textSize="18dp" />
      </LinearLayout>
      <View
          android:layout_width="match_parent"
          android:layout_height="1px"
          android:background="@color/menu_text_color" />
      <LinearLayout
          android:orientation="horizontal"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:padding="15dp"
          android:id="@+id/voiceCommandsButton">
        <TextView
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="VOICE COMMANDS"
            android:textSize="18dp" />
      </LinearLayout>
      <View
          android:layout_width="match_parent"
          android:layout_height="1px"
          android:background="@color/menu_text_color" />
      <LinearLayout
          android:orientation="horizontal"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:padding="15dp"
          android:id="@+id/feedbackButton">
        <TextView
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="GIVE FEEDBACK"
            android:textSize="18dp" />
      </LinearLayout>
      <View
          android:layout_width="match_parent"
          android:layout_height="1px"
          android:background="@color/menu_text_color" />
      <LinearLayout
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:padding="15dp">
        <TextView
            android:text="Data Sources:"
            android:gravity="center"
            android:textSize="17dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
        <CheckBox
            android:text="1 (default)"
            android:id="@+id/dataSourceStateHighways"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
        <CheckBox
            android:text="2"
            android:id="@+id/dataSourceCouncils"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
      </LinearLayout>
      <View
          android:layout_width="match_parent"
          android:layout_height="1px"
          android:background="@color/menu_text_color" />
    </LinearLayout>
  </ScrollView>

从示例图像中可以看出,没有以黄色突出显示的行:

最奇怪的是,在 Android 设备监视器 DDMS 的转储视图中查看时会显示该行:

(Whosebug 不允许我 post 我的问题,因为它没有足够的文本,所以我只写了几次)(Whosebug 不允许我 post 我的问题,因为它没有足够的文字,所以我只写了几次)

您需要在 100% 缩放模式下使用模拟器。如果您正在模拟全高清屏幕,但您的模拟器是全高清显示器的 1/4,在某些情况下 1px 线可能不可见。您可以通过在 ScrollView 中添加更多 "dumb" 布局来测试它,以便它开始滚动。在滚动过程中,您会看到这些线条在闪烁。您应该不会在真实设备(或模拟器的屏幕截图)上看到此问题