Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Padding arround textview with nine patch background have no visual effect

Im trying to 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: enter image description here

this is textview with drawable background : enter image description here

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 ?

like image 211
Alexey Kruchenok Avatar asked Jan 31 '11 21:01

Alexey Kruchenok


1 Answers

Try any of these:

  1. Set the background ninepatch via the "android:background" xml property instead of programatically; this cooperates with XML-defined padding.
  2. 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).
  3. Avoid the entire issue and just set the padding areas in your ninepatch image itself (that's the right and bottom black bars).
like image 74
Yoni Samlan Avatar answered Nov 15 '22 15:11

Yoni Samlan