android


Why is each element in the table row still taking the same amount of space


Here is what I am getting when I run my application on my device
The part that I have problems with is the rows - with text, quote, and web. I dynamically inserted those rows into the scroll view at runtime. Here is my xml code that I used for layout inflating
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent" >
<TextView
android:id="#+id/stockView"
android:text="TextView"
android:layout_weight="2" />
<Button
android:id="#+id/stockQuote"
style="?android:attr/buttonStyleSmall"
android:text="#string/get_stock_quote"
android:layout_weight="1" />
<Button
android:id="#+id/webStock"
style="?android:attr/buttonStyleSmall"
android:text="#string/go_to_website"
android:layout_weight="1" />
</TableRow>
My question is with this code, why is each element still taking the same amount of space. I know that because I specified the text view's layout_weight to 2, it should take up half of the width with each button taking 1/4 of the total width. I know this isn't bc of weight sum as weight sum by default is 4 in this case. Does anyone know how i can get the text view to take up 1/2 of its parent's width?
Check this it works..
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent" >
<TextView
android:id="#+id/stockView"
android:layout_width="0dip"
android:text="TextView"
android:layout_weight="2" />
<Button
android:id="#+id/stockQuote"
android:layout_width="0dip"
style="?android:attr/buttonStyleSmall"
android:text="get_stock_quote"
android:layout_weight="1" />
<Button
android:id="#+id/webStock"
android:layout_width="0dip"
style="?android:attr/buttonStyleSmall"
android:text="go_to_website"
android:layout_weight="1" />
You should play with layout_span. Try to add android:layout_span="2" to your textview.
What is the equivalent of "colspan" in an Android TableLayout?

Related Links

How to add onKeyUp()/onKeyDown() to an activity/view that I do not create?
Android listview actionlistener
App created in corona gets an error in android device
Could not execute adb command on the terminal of ubuntu 64 bit
correct use of Android onSaveInstanceState()
Is there a tool to remove unwanted ,unused variable [closed]
Need to reflect text in textView android
pixels within a specific portion of screen Android [duplicate]
What will my Apps URL be in google play when i publish it?
How to make a search dialog with ActionBarSherlock?(not search)
Android Spinner is empty
Problems with the button to graph in achartengine
How to catch mediaplayer datasource no file error?
setting onclick image for image button in android
hide the top menu bar in my android device & Tablet
Android: How to run an activity inside a fragment?

Categories

HOME
cygwin
httparty
google-cloud-platform
pda
static
yahoo-finance
grafana
switch-statement
square
retrofit2
odoo-8
modal-dialog
special-characters
pattern-matching
enthought
activecollab
why3
libc
bitnami
event-sourcing
google-content-api
symfony-console
sencha-touch
imageresizer
strongname
jquery-multiselect
bulletphysics
amazon-quicksight
apktool
spotipy
recurring-events
paragraph
python-import
pdw-file-browser
xdocreport
apns-php
signals-slots
comparison-operators
vmware-fusion
apriori
branching-and-merging
escpos
microsoft-metro
lpsolve
file-sharing
wc
uiimage
spring-integration-sftp
globalize
fclose
vugen
corruption
payara-micro
spring-data-couchbase
ngmaterial
arules
dt
quicktime
libjpeg
mach-o
javafx-css
visual-studio-2008-sp1
cronexpression
meteor-packages
flex-monkey
ziparchive
redbeard-ios
webjars
google-query-language
data-protection
exim4
contentcontrol
crouton-os
libvlc
dynamics-nav-2016
gocql
dllimport
telepat
matlab-deployment
entity-framework-4.3
broadband
genymotion-call
cancellation
maven-scm
websphere-esb
gae-quotas
clickbank
openargs
artemis
gtm-oauth2
embedded-fonts
gpars
abstract-data-type
dopostback
window-decoration
floating-point-exceptions
cgimage
relative
procedures
landscape-portrait
django-paypal
instantiationexception
web-garden
application-verifier
qtabbar
lalr
visualj#
google-wave

Resources

Encrypt Message