开发者

Padding arround textview with nine patch background have no visual effect

开发者 https://www.devze.com 2023-02-07 14:49 出处:网络
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.

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:

Padding arround textview with nine patch background have no visual effect

this is textview with drawable background :

Padding arround textview with nine patch background have no visual effect

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:

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

精彩评论

暂无评论...
验证码 换一张
取 消