开发者

How to display background image in text view

can any开发者_开发技巧body tell how to display background image in a TextView in android?


If you are working with xmls you can add it as Praveen Chandrasekaran said doing:

android:background="@drawable/myResouce"

Before that you have to put your image file inside the res/drawable folder.

You can also change it from the code doing:

  mTextView.setBackgroundResource(R.drawable.myResouce);


add a android:background="@drawable/imagefile" attribute on your TextView tag. Before that you have to put your image file inside the res/drawable folder.


android:background="@drawable/mark"

Also review.... your background image should be a 9.png and add some paddings for your content

           android:layout_marginLeft="10dp" android:layout_marginRight="10dp"
            android:layout_height="400dp" android:background="@drawable/mark"
            android:paddingTop="5dp" android:paddingBottom="5dp" android:paddingLeft=
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜