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

Android : Change cart menu badge counter from Recycler Adapter
Position imageview relative to another imageview
Android Studio Density
Use Custom Class to Grant Permission
How to automatically push cordova app to playstore
Transition in navigation drawer android
Espresso testing ListView
Using tab-completed directory names in bash
Android - How kill process with ppid = 1
Chromecast does not resume after pause with error 2100
main Layout Overlaps with Navigation Drawer
Firebase Realtime Database is taking too much time for the first time connection
Android - Recycler View item get swapped when scrolled
Mock location Check failed with “Fake GPS Go”
grid/table cell expanding to use available space
Error while removing fragment containing videoView in 4.0.4

Categories

HOME
c++11
rsa
devise
replace
mips
nested-if
android-json
bing-maps
32bit-64bit
dkim
mel
opengl-es-3.0
heat
internationalization
google-data-studio
google-picker
topology
asp.net-core-webapi
asciidoctor-pdf
cgbitmapcontext
inno-download-plugin
visual-studio-extensions
imageresizer
displaytag
resourcebundle
angular-translate
user-defined-functions
twiml
finagle
gitlab-api
cart
jbutton
wacom
biztalk-rule-engine
getpixel
python-pptx
playframework-2.1
graphhopper
protein-database
filesystemwatcher
gdata
railstutorial.org
typesafe-config
numberpicker
microsoft-metro
ssrs-2014
ntvs
dbcontext
pair-programming
amq
context-switch
boxing
skin
boo
pdf-conversion
pybrain
cd-burning
django-1.10
stax
xcode-server
myspace
flex4.6
embedding
google-query-language
fuzzywuzzy
mobiledoc-kit
dynatree
doctype
atoi
sql-server-data-tools
ms-access-2000
jquery-forms-plugin
j-security-check
broadband
openbabel
qtwebengine
mass-assignment
dbaccess
browserify-shim
iso-prolog
cbind
human-computer-interface
raygun
trdion2011
matrix-inverse
tinyxml
renderer
koala
conditionaltagsupport
visual-studio-express
jammer
jeromq
hidapi
robotlegs
android-loadermanager
objectquery
denied
unattended-processing
resharper-6.0
instantiationexception
cruisecontrol.rb
silent
eclipse-marketplace
hbm2java
qtabbar
wcf-instancing
fail-fast-fail-early
firefox-3
soappy

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