use relativelayouts in weekly view for easier overlap handling

This commit is contained in:
tibbi
2017-01-18 23:17:19 +01:00
parent b8d71620aa
commit 5dacb916ca
2 changed files with 18 additions and 24 deletions

View File

@@ -8,7 +8,7 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.ViewTreeObserver import android.view.ViewTreeObserver
import android.widget.LinearLayout import android.widget.RelativeLayout
import android.widget.TextView import android.widget.TextView
import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.activities.MainActivity import com.simplemobiletools.calendar.activities.MainActivity
@@ -103,9 +103,10 @@ class WeekFragment : Fragment(), WeeklyCalendar {
background = ColorDrawable(eventColor) background = ColorDrawable(eventColor)
activity.runOnUiThread { activity.runOnUiThread {
layout.addView(this) layout.addView(this)
(layoutParams as LinearLayout.LayoutParams).apply { (layoutParams as RelativeLayout.LayoutParams).apply {
rightMargin = sideMargin rightMargin = sideMargin
topMargin = (startMinutes * minuteHeight).toInt() topMargin = (startMinutes * minuteHeight).toInt()
width = layout.width
height = (duration * minuteHeight).toInt() - sideMargin height = (duration * minuteHeight).toInt() - sideMargin
} }
} }
@@ -113,7 +114,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
} }
} }
private fun getColumnWithId(id: Int) = mView.findViewById(mRes.getIdentifier("week_column_$id", "id", context.packageName)) as LinearLayout private fun getColumnWithId(id: Int) = mView.findViewById(mRes.getIdentifier("week_column_$id", "id", context.packageName)) as RelativeLayout
fun setListener(listener: WeekScrollListener) { fun setListener(listener: WeekScrollListener) {
mListener = listener mListener = listener

View File

@@ -102,61 +102,54 @@
android:background="@android:color/transparent" android:background="@android:color/transparent"
android:orientation="horizontal"> android:orientation="horizontal">
<LinearLayout <RelativeLayout
android:id="@+id/week_column_0" android:id="@+id/week_column_0"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:background="@android:color/transparent" android:background="@android:color/transparent"/>
android:orientation="vertical"/>
<LinearLayout <RelativeLayout
android:id="@+id/week_column_1" android:id="@+id/week_column_1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:background="@android:color/transparent" android:background="@android:color/transparent"/>
android:orientation="vertical"/>
<LinearLayout <RelativeLayout
android:id="@+id/week_column_2" android:id="@+id/week_column_2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:background="@android:color/transparent" android:background="@android:color/transparent"/>
android:orientation="vertical"/>
<LinearLayout <RelativeLayout
android:id="@+id/week_column_3" android:id="@+id/week_column_3"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:background="@android:color/transparent" android:background="@android:color/transparent"/>
android:orientation="vertical"/>
<LinearLayout <RelativeLayout
android:id="@+id/week_column_4" android:id="@+id/week_column_4"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:background="@android:color/transparent" android:background="@android:color/transparent"/>
android:orientation="vertical"/>
<LinearLayout <RelativeLayout
android:id="@+id/week_column_5" android:id="@+id/week_column_5"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:background="@android:color/transparent" android:background="@android:color/transparent"/>
android:orientation="vertical"/>
<LinearLayout <RelativeLayout
android:id="@+id/week_column_6" android:id="@+id/week_column_6"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:background="@android:color/transparent" android:background="@android:color/transparent"/>
android:orientation="vertical"/>
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>