From edb190a8c0bd40e63f6c3c2e328cc0391849eade Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Fri, 30 Nov 2018 21:04:32 +0000 Subject: [PATCH] fixed min amount width of 40dp (abt. 6 digits) --- .../java/net/ktnx/mobileledger/NewTransactionActivity.java | 6 +++++- app/src/main/res/layout/content_new_transaction.xml | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java b/app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java index 1ff9431b..a35c472c 100644 --- a/app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java @@ -7,6 +7,7 @@ import android.support.v4.app.DialogFragment; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.text.InputType; +import android.util.TypedValue; import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; @@ -81,6 +82,9 @@ public class NewTransactionActivity extends AppCompatActivity { // .setAction("Action", null).show(); } + public int dp2px(float dp) { + return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, getResources().getDisplayMetrics())); + } public void addTransactionAccountFromMenu(MenuItem item) { final AutoCompleteTextView acc = new AutoCompleteTextView(this); acc.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT, 9f)); @@ -92,7 +96,7 @@ public class NewTransactionActivity extends AppCompatActivity { amt.setHint(R.string.new_transaction_amount_hint); amt.setWidth(0); amt.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL ); - amt.setMinWidth(64); + amt.setMinWidth(dp2px(40)); amt.setTextAlignment(EditText.TEXT_ALIGNMENT_VIEW_END); final TableRow row = new TableRow(this); diff --git a/app/src/main/res/layout/content_new_transaction.xml b/app/src/main/res/layout/content_new_transaction.xml index 28f393d1..7ea277bd 100644 --- a/app/src/main/res/layout/content_new_transaction.xml +++ b/app/src/main/res/layout/content_new_transaction.xml @@ -55,7 +55,7 @@ android:width="0dp" android:hint="@string/new_transaction_amount_hint" android:inputType="numberDecimal|numberSigned" - android:minWidth="24pt" + android:minWidth="40dp" android:nextFocusDown="@id/new_transaction_acc_2" android:nextFocusForward="@id/new_transaction_acc_2" android:textAlignment="viewEnd" /> @@ -83,7 +83,7 @@ android:width="0dp" android:hint="@string/new_transaction_amount_hint" android:inputType="numberDecimal|numberSigned" - android:minWidth="24pt" + android:minWidth="40dp" android:textAlignment="viewEnd" /> -- 2.39.5