我尝试创建一个布局(日视图日历),其中texviews(任务)被垂直列出(按时间安排)。 TextView高度始终如一般地按照任务持续时间。问题是当两个或多个任务具有相同的调度时间时,我无法共享水平空间。那是因为我使用相对布局而且我不能使用权重,因此在这种情况下,一个textview在另一个之上。我无法使用LinearLayout,因为任务之间可能存在间隙。无论如何要处理它吗?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android1="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android1:layout_width="fill_parent"
android1:layout_height="fill_parent" >
<LinearLayout
android1:layout_width="wrap_content"
android1:layout_height="fill_parent"
android1:orientation="vertical" >
<TextView
android1:id="@+id/tv_00"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="00 πμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_01"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="01 πμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_02"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="02 πμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_03"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="03 πμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_04"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="04 πμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_05"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="05 πμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_06"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="06 πμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_07"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="07 πμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_08"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="08 πμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_09"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="09 πμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_10"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="10 πμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_11"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="11 πμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_12"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="12 πμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_13"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="01 μμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_14"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="02 μμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_15"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="03 μμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_16"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="04 μμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_17"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="05 μμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_18"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="06 μμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_19"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="07 μμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_20"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="08 μμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_21"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="09 μμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_22"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="10 μμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_23"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="11 μμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
<TextView
android1:id="@+id/tv_24"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:gravity="center_vertical"
android1:height="@dimen/crm_calendar_time_row_height"
android1:text="12 μμ"
android1:textAppearance="?android:attr/textAppearanceMedium"
android1:textColor="@color/crm_calendar_time_row_color" />
</LinearLayout>
<RelativeLayout
android1:id="@+id/rl_schedule"
android1:layout_width="fill_parent"
android1:layout_height="fill_parent"
android1:orientation="vertical" >
</RelativeLayout>
</LinearLayout>
</ScrollView>
<resources>
<dimen name="crm_calendar_time_row_height">40dp</dimen>
<color name="crm_calendar_time_row_color">#BBBBBB</color>
</resources>
这是我的布局。我想在RelativeLayout中动态创建任务,但正如我所提到的,当任务具有相同的调度时间时,我无法共享它的空间。