fixed min amount width of 40dp (abt. 6 digits)
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 30 Nov 2018 21:04:32 +0000 (21:04 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 30 Nov 2018 21:04:32 +0000 (21:04 +0000)
app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java
app/src/main/res/layout/content_new_transaction.xml

index 1ff9431b8f8cd2e25364dd3112097585e2fef98d..a35c472c66bb70daeb8338784631d69ecc89d84a 100644 (file)
@@ -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);
index 28f393d1dbe002c2b8915dacdeb8e722ad1743d4..7ea277bddb0425755916cde5fecef33f7443e755 100644 (file)
@@ -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" />
                 </TableRow>