android


How to get the width of a text view in an action bar?


I have an action bar with a title. Another string is added dynamically to the action bar. I have tried using OnSizeChanged and addOnLayoutListener to resize the action bar title according to the length of the string added latter.The action bar title is resized properly most of the times.
The issue is whenever a shorter string is dynamically added after a longer string, the size of the title is not increased. The width of the title text view remains when a shorter string replaces longer string.
Create a new LayoutParams object and assign it to your textView :
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1f);
textview.setLayoutParams(params );
The last parameter of the LayoutParams constructor is the weight and allows you to fill the available space with the TextView.

Related Links

Converting callback which will be invoked infinite number of times to Observable
How to launch Chrome Dev Tools device “inspect” programmatically?
Dynamically change the size of cells and spacing in grid layout android
RecyclerView overlapping without shadow
Parsing a JSON file without arrays
Custom view uses data binding but layout is include'd, how can the view be aware of its own binding?
List item is detached from ListView even they are supposed to be shown on screen (Android 7.0)
Could not find support-v4.jar (com.android.support:support-v4:24.0.0)
Calling ShowViewModel on activity, does not show Child fragment
Retrofit gives connection timeout while uploading image using wifi with static ip address
Keep showing popupWindow when back button of keyboard is pressed
Invalid IP address from connecting HTTP client in Android studio
Chrome updates on Android emulator
How to set two or more DatePicker and Display it on TextView?
Hello World App crashing in Cordova 6.4.0
Andriod Listview fast scroll to bottom automatically when scroll in the middle

Categories

HOME
go
search
azure-stream-analytics
checkstyle
fuelux
linkedin
formal-languages
pyqt
obfuscation
entity-framework-core
mips
bookmarks
data-visualization
discrete-mathematics
endeca
java.util.logging
ipmitool
magnetic-cards
altera
azure-powershell
asp.net-mvc-viewmodel
shortest-path
articulate-storyline
blade
jquery-ias
hta
epsilon
asymptotic-complexity
intersystems-cache
handler
android-things
paperjs
comparable
sqlpackage
boost-asio
zend-debugger
code-snippets
hard-drive
sendbird
hunspell
least-squares
navigator
protege4
sim-toolkit
wurfl
zoomify
connection-pool
filesystemwatcher
recurrent-neural-network
opensmpp
watchface
ssrs-2014
rfc3339
dynamic-linq
opennms
fclose
rserve
bluez
remedy
boxing
excel-dna
er-diagram
pdf-conversion
trigger.io
cmp
google-cloud-console
file-uri
rspec2
jboss-tools
dimension
freepbx
lua-telegram-bot
boost-serialization
atan2
toran-proxy
vigenere
extjs-grid
binomial-theorem
dulwich
mirror
snoop
nutiteq
adehabitathr
cross-join
clickbank
conditionaltagsupport
kogrid
scringo
scmmanager
patricia-trie
correlated-subquery
thttpd
fusefabric
hibernateexception
relative
update-statement
quotation-marks
load-time
instantiationexception
hbm2java
addchild
scrollbars
pagemethods
interop-domino
flvplayback
wspbuilder

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App