diff --git a/app/src/main/java/com/kunzisoft/keepass/activities/fragments/EntryEditFragment.kt b/app/src/main/java/com/kunzisoft/keepass/activities/fragments/EntryEditFragment.kt
index e8ffc2067..cfb707281 100644
--- a/app/src/main/java/com/kunzisoft/keepass/activities/fragments/EntryEditFragment.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/activities/fragments/EntryEditFragment.kt
@@ -20,6 +20,7 @@
package com.kunzisoft.keepass.activities.fragments
import android.graphics.Color
+import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
@@ -112,6 +113,12 @@ class EntryEditFragment : StylishFragment() {
entryTitleView = rootView.findViewById(R.id.entry_edit_title)
templateContainerView = rootView.findViewById(R.id.template_fields_container)
+ // To fix card view margin in KitKat-
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
+ val paddingVertical = resources.getDimensionPixelSize(R.dimen.card_view_margin_vertical)
+ val paddingHorizontal = resources.getDimensionPixelSize(R.dimen.card_view_margin_horizontal)
+ templateContainerView.setPadding(paddingHorizontal, paddingVertical, paddingHorizontal, paddingVertical)
+ }
customFieldsContainerView = rootView.findViewById(R.id.custom_fields_container)
attachmentsContainerView = rootView.findViewById(R.id.entry_attachments_container)
diff --git a/app/src/main/java/com/kunzisoft/keepass/view/SectionView.kt b/app/src/main/java/com/kunzisoft/keepass/view/SectionView.kt
index 05a4e26bb..f39f7d3be 100644
--- a/app/src/main/java/com/kunzisoft/keepass/view/SectionView.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/view/SectionView.kt
@@ -25,6 +25,7 @@ import android.view.View
import android.widget.LinearLayout
import androidx.annotation.IdRes
import androidx.cardview.widget.CardView
+import androidx.core.view.setPadding
import com.kunzisoft.keepass.R
class SectionView @JvmOverloads constructor(context: Context,
@@ -33,18 +34,17 @@ class SectionView @JvmOverloads constructor(context: Context,
: CardView(context, attrs, defStyle) {
private var containerSectionView = LinearLayout(context).apply {
- val margin = resources.getDimension(R.dimen.card_view_padding).toInt()
+ val padding = resources.getDimensionPixelSize(R.dimen.card_view_padding)
layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
- LinearLayout.LayoutParams.WRAP_CONTENT).also {
- it.setMargins(margin, margin, margin, margin)
- }
+ LinearLayout.LayoutParams.WRAP_CONTENT)
+ setPadding(padding)
orientation = LinearLayout.VERTICAL
}
init {
- val marginHorizontal = resources.getDimension(R.dimen.card_view_margin_horizontal).toInt()
- val marginVertical = resources.getDimension(R.dimen.card_view_margin_vertical).toInt()
+ val marginHorizontal = resources.getDimensionPixelSize(R.dimen.card_view_margin_horizontal)
+ val marginVertical = resources.getDimensionPixelSize(R.dimen.card_view_margin_vertical)
layoutParams = LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT).also {
diff --git a/app/src/main/res/layout/activity_entry_edit.xml b/app/src/main/res/layout/activity_entry_edit.xml
index 8db12816d..7b548396f 100644
--- a/app/src/main/res/layout/activity_entry_edit.xml
+++ b/app/src/main/res/layout/activity_entry_edit.xml
@@ -70,7 +70,7 @@
app:layout_constraintWidth_percent="@dimen/content_percent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/entry_edit_template_selector" />
+ app:layout_constraintTop_toBottomOf="@+id/entry_edit_template_selector"/>
diff --git a/app/src/main/res/layout/item_template.xml b/app/src/main/res/layout/item_template.xml
index 8ae8f1c5e..035d56a76 100644
--- a/app/src/main/res/layout/item_template.xml
+++ b/app/src/main/res/layout/item_template.xml
@@ -16,41 +16,48 @@
* You should have received a copy of the GNU General Public License
* along with KeePassDX. If not, see .
-->
-
-
-
-
-
+
-
+ style="?attr/cardViewStyle">
+
+
+
+
+
+
+