Android “Ajouter une ligne verticale” sur “RelativeLayout” / “Linéaire”Mise en page

J'ai lu d'autres questions à propos de l'ajout d'une ligne verticale dans Android, voici mes questions

  1. J'ai pu ajouter une ligne verticale comme une "Vue" sous mon principal RelativeLayout, mais ne parvient pas à le faire à l'intérieur des sous RelativeLayout.

code pour une ligne verticale

<View
android:id="@+id/verticalSeperatorHours"
android:layout_width="1dip"
android:layout_height="match_parent"
android:background="@color/medium_dark_gray" 
/>

code pour une ligne horizontale:

<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>

Ma structure xml:

  • RelativeLayout
    • LinearLayout
    • ScrollView
      • RelativeLayout
        • RelativeLayout
        • "Ajout d'une ligne verticale ne fonctionne pas"
        • "Ajout d'une ligne horizontale œuvres"
  • LinearLayout
  • L'ajout d'une ligne verticale ici fonctionne, mais pas ce que je veux"

La "Vue" après le LinearLayout de la ligne horizontale n'apparaît pas. J'ai réalisé que je n'avais pas à comprendre la structure d'android disposition en profondeur, donc quelqu'un peut-il m'expliquer comment il fonctionne.

Mise En Page:

<?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"
        android:padding="0dp" >

        <LinearLayout ...


        <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>
        <View
                android:id="@+id/verticalSeperatorHours"
                android:layout_width="1dip"
                android:layout_height="match_parent"
                android:layout_marginLeft="100dp"
                android:background="@color/medium_dark_gray" />
    </RelativeLayout>
</ScrollView>



<LinearLayout ...

<View ...

</RelativeLayout>
  • Eh bien, c'était une nouvelle manière de montrer votre mise en page. Merci d'éditer et de montrer votre mise en page XML au lieu de simplement votre "structure" et de votre "ligne horizontale".
InformationsquelleAutor Chong Yue | 2013-09-14