Im trying to开发者_C百科 create toast like control based on textview, and i found very strange behavior of textview in case when it have nine patch drawable as background.
This is xml definition:
<by.pplware.view.QuickInfo
android:id="@+id/quickinfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:padding="20px"
android:textSize="20px"
android:textStyle="bold"
android:typeface="serif"
android:background="#FFFF0000"
/>
this is textview with color background:
this is textview with drawable background :
As i understand, in case of ninepatch background android make padding transparent and use drawable only as background for text. But I want to include padding into area covered with ninepatch background.
Is there any solution for this issue ?
Try any of these:
- Set the background ninepatch via the "android:background" xml property instead of programatically; this cooperates with XML-defined padding.
- If you need to set the background programatically, try to re-set the padding after setting the background (if you set the padding then set the background, I'd assume the padding defined in the ninepatch itself overrides it).
- Avoid the entire issue and just set the padding areas in your ninepatch image itself (that's the right and bottom black bars).
精彩评论