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.
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