Measuring text width to be drawn on Canvas ( Android )
Have you looked at android.graphics.Paint#measureText(String txt)?
Have you looked at android.graphics.Paint#measureText(String txt)?
Do you really need to do that programmatically? Just considering the title: You could use a ShapeDrawable as android:background… For example, let’s define res/drawable/my_custom_background.xml as: <shape xmlns:android=”http://schemas.android.com/apk/res/android” android:shape=”rectangle”> <corners android:radius=”2dp” android:topRightRadius=”0dp” android:bottomRightRadius=”0dp” android:bottomLeftRadius=”0dp” /> <stroke android:width=”1dp” android:color=”@android:color/white” /> </shape> and define android:background=”@drawable/my_custom_background”. I’ve not tested but it should work. Update: I think that’s better to … Read more
I usually use this code to add horizontal line: <View android:layout_width=”match_parent” android:layout_height=”1dp” android:background=”@android:color/darker_gray”/> To add vertical separator, switch the layout_width and layout_height values