android-iconify
android-iconify copied to clipboard
Gravity is not working correct
Hi! I think there is a problem with centering the content of the IconTextView when the text is set after the first layout.
In my app i have a dashboard with tiles. some of them are static and some of them loaded via network from a webservice. The loading is done with a AsyncThread. When i try so set the icon in onPostExecute the icon is not centered correct.
Here is a Example:
The tile with the label "Baupläne (2)" is static and the icon is set during the view creation. The other one with the label "Baupläne (1)" is dynamic, the icon leaved empty and creation and is set after the content is loaded from the server.
This is the layout ressource i used:
<com.joanzapata.iconify.widget.IconTextView
android:id="@+id/dashboardTile_icon"
android:layout_width="match_parent"
android:layout_height="@dimen/dashboardTiles_iconSize"
android:layout_gravity="top"
android:layout_marginTop="@dimen/dashboardTiles_iconMarginTop"
android:gravity="center"
android:textSize="@dimen/dashboardTiles_iconSize"
android:textColor="#FFFFFF" />
nothing of the view is changed by code except the text and textColor.
Any Ideas for a workaround or a fix?
adding android:bufferType="spannable"
seems to fix the problem, but i don't know exactly why. Maybe someone coudl explain the issue.
Interesting. I don't where the problem comes from, I've had use cases like yours but all went fine. I'll try to reproduce and fix it, thanks for sharing a workaround!
I have the same problem with TextView gravity too. When i change TextView width in method onMeasure, the icon doesn't adjust itself to the new width.