From e5f50a712c279e7c6ffb701ab3b0013ca4ad5e21 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Fri, 7 Dec 2018 18:47:57 +0000 Subject: [PATCH] center vertically the text in the account row --- app/src/main/java/net/ktnx/mobileledger/AccountSummary.java | 3 +++ app/src/main/res/layout/content_account_summary.xml | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java b/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java index 85934300..12436d5c 100644 --- a/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java +++ b/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java @@ -16,6 +16,7 @@ import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; import android.util.TypedValue; +import android.view.Gravity; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -204,6 +205,7 @@ public class AccountSummary extends AppCompatActivity { TableLayout t = new TableLayout(this); TableRow r = new TableRow(this); r.setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + r.setGravity(Gravity.CENTER_VERTICAL); r.setPadding(getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin), dp2px(4), getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin), dp2px(4)); if (even) r.setBackgroundColor(getResources().getColor(R.color.table_row_even_bg, getTheme())); @@ -217,6 +219,7 @@ public class AccountSummary extends AppCompatActivity { TextView amt_tv = new TextView(this, null, R.style.account_summary_amounts); amt_tv.setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1f)); amt_tv.setTextAlignment(EditText.TEXT_ALIGNMENT_VIEW_END); + amt_tv.setGravity(Gravity.CENTER); amt_tv.setMinWidth(dp2px(40f)); StringBuilder amt_text = new StringBuilder(); try (Cursor cAmounts = db.rawQuery("SELECT currency, value FROM account_values WHERE account = ?", new String[]{acc_name})) { diff --git a/app/src/main/res/layout/content_account_summary.xml b/app/src/main/res/layout/content_account_summary.xml index 958cf4c9..30a1d60f 100644 --- a/app/src/main/res/layout/content_account_summary.xml +++ b/app/src/main/res/layout/content_account_summary.xml @@ -52,6 +52,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/table_row_even_bg" + android:gravity="center" android:paddingStart="@dimen/activity_horizontal_margin" android:paddingEnd="@dimen/activity_horizontal_margin"> @@ -63,7 +64,7 @@ + android:text="123,45\n678,90" /> -- 2.39.5