android


android layout: edittext shifting right and left


I am working on a calculator where on the "screen" the left part shows the symbol + - * / and the right shows the digits. The size of the symbol cannot be too small, but when the user presses for the symbol and the symbol shows e.g. +, the figures on the right will shift rightwards a bit in order to accomodate the symbol.
The figure on the right keep shifting rightwards when have symbol while back to its place when no symbols. Also, the symbol cannot be shown properly. This is frustrating.
Yet I would like to maintain that the symbol and the figures be maintained within 1 row such that it really looks like calculator. How could this be handled? The layout code is as follows. Thanks in advance!!!!
<TableRow
android:id="#+id/tableRow3"
android:layout_weight="0.1"
android:background="#android:color/white"
android:paddingLeft="0dp"
android:paddingRight="0dp" >
<EditText
android:id="#+id/symEditText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="left"
android:layout_span="1"
android:background="#android:color/transparent"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="right|center_vertical"
android:inputType="numberDecimal"
android:longClickable="false"
android:maxLength="3"
android:paddingRight="0dp"
android:text=""
android:textColor="#003366"
android:textSize="14dp"
android:textStyle="bold" >
</EditText>
<EditText
android:id="#+id/ansEditText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="right"
android:layout_span="9"
android:background="#android:color/transparent"
android:clickable="false"
android:ems="4"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="right|center_vertical"
android:inputType="numberDecimal"
android:longClickable="false"
android:maxLength="23"
android:paddingRight="20dp"
android:textColor="#003366"
android:textSize="#dimen/display_text_size"
android:textStyle="bold" >
<requestFocus />
</EditText>
</TableRow>
You should only use TableRow inside a TableLayout. I think you can just use a horizontal LinearLayout instead. If you want to always maintain a space to show a symbol, give that view a fixed width instead of using wrap_content, otherwise it will grow/shrink when the content changes. (make sure to specify your width in dp units)
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/symbol"
android:layout_width="20dp" <!-- fixed size -->
android:layout_height="wrap_content"
<!-- more attributes -->
</TextView>
<TextView
android:id="#+id/answer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" <!-- fill remaining space -->
android:gravity="right"
<!-- more attributes -->
</TextView>
</LinearLayout>

Related Links

How to Retrieve the EXISTING_FILE_ID when Integrating google drive
Android Listview OnItemClickListener sometimes not working
Send message to user in WhatsApp from my app (Android)
How to get execute query string in sqlite for android?
Does we have possibility to get current speed in android without GPS? [closed]
Android custom adapter getView() NullPointerException
toggling between front and back camera without going back to home screen using ADB
Android: reset if reopened after launching external Intent
Google Photos vs Stock Gallery - Intent Picker
Android MapView API v2 not rendering, tried it all
What version of Graph API is exposed via the FB SDK for Android / iOS when running a FQL query?
FATAL Exception Main in android
how to Implement navigation drawer and Android Menus in same activity
Google map cluster with direction
Trying to update ADT - receiving “conflicting dependency” error
Android: How to vertically-align:top a Radio button to a multiline text?

Categories

HOME
go
eclipse
design-patterns
forms
amp-html
youtube-data-api-v3
yahoo-finance
serialization
oracle-apex-5
alarm
regular-language
jquery-ui
android-json
banner
flume
character
elasticsearch-5
pega
startup
xcodebuild
tput
nancy
magnetic-cards
symbol
azure-powershell
internationalization
glyphicons
job-scheduling
mathprog
windows-xp
dataflow-diagram
perlbrew
corpus
progress-bar
tizen-tv
mockjax
playstation-portable
android-gridview
arduino-ide
baidu-map
video-capture
flatmap
chef-solo
naming
linqpad
bindingnavigator
android-exoplayer
procfile
fwrite
proget
builder
dt
java-websocket
janus
lsyncd
swingworker
hadoop-2.7.2
preprocessor
segment-io
google-cloud-console
x-tag
dup
mediametadataretriever
cda
design-principles
vhosts
intel-c++
zen-cart
android-launcher
mod-proxy
eoferror
jsvc
git-ftp
zend-currency
shopizer
broadband
code-documentation
nodelist
ghcjs
genymotion-call
unix-socket
kissfft
personalization
mintty
menubar
scriptaculous
artemis
breakout
away3d
model-driven-development
ebay-lms
pagedown
chart-director
midlet
oracle-enterprise-linux
window-decoration
hibernateexception
appledoc
ruby-1.8
silent
vs-android
hbm2java
feasibility
technical-debt
httpcookie

Resources

Encrypt Message