我尝试创建一个布局(日视图日历),其中 texviews(任务)垂直列出(按时间安排)。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 中动态创建任务,但正如我提到的,当任务具有相同的计划时间时,我不能水平共享它的空间。