小编Cho*_*Yue的帖子

Android在“ RelativeLayout” /“ Linear Layout”上“添加垂直线”

我已经阅读了有关在Android中添加垂直线的其他问题,这是我的问题

  1. 我可以在主RelativeLayout下添加一条垂直线作为“视图”,但是在子RelativeLayout中却无法做到。

垂直线代码

<View
android:id="@+id/verticalSeperatorHours"
android:layout_width="1dip"
android:layout_height="match_parent"
android:background="@color/medium_dark_gray" 
/>
Run Code Online (Sandbox Code Playgroud)

水平线代码:

<LinearLayout
            android:id="@+id/currentTimeMarkerLinearLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="0dp"
            android:layout_marginTop="100dp"
            android:baselineAligned="false"
            android:orientation="horizontal"
            android:padding="0dp" >

            <View
                android:layout_width="0dp"
                android:layout_height="3dp"
                android:layout_weight="1" />

            <View
                android:id="@+id/currentTimeLineView"
                android:layout_width="0dp"
                android:layout_height="1dp"
                android:layout_weight="14"
                android:background="@color/strong_blue" />
        </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我的结构xml:

  • 相对布局
    • 线性布局
    • 滚动视图
      • 相对布局
        • 相对布局
        • “添加垂直线不起作用”
        • “添加一条水平线有效”
  • 线性布局
  • 在此处添加垂直线有效,但不是我想要的”

没有出现水平线的LinearLayout之后的“视图”。我意识到我不了解android布局的结构,因此有人可以向我解释它的工作原理。

完整版式:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:arm="http://schemas.android.com/apk/res/edu.cmu.sv.arm"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="0dp" >

<LinearLayout ...


<View
    android:id="@+id/dividerView"
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:layout_below="@+id/dayLabelsLinearLayout"
    android:background="@color/medium_gray" />

<ScrollView
    android:id="@+id/calendarScrollView"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+id/dividerView"
    android:layout_alignParentBottom="true"
    android:overScrollMode="never"
    android:padding="0dp"
    android:scrollbars="none"
    android:fadingEdge="none" >

    <RelativeLayout
        android:id="@+id/calendarRelativeLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android relativelayout android-layout android-linearlayout

3
推荐指数
1
解决办法
2万
查看次数