【发布时间】:2015-11-11 21:21:43
【问题描述】:
【问题讨论】:
标签: android xml textview android-custom-view
【问题讨论】:
标签: android xml textview android-custom-view
在代码中使用 setBackgroundResource(int resourceId) 或在布局中使用 android:background。
Java:
mTextView.setBackgroundResource(R.drawable.yourDrawable);
布局:
<TextView
android:background="@drawable/yourDrawable"
...
/>
【讨论】:
创建这样的布局。您必须为此使用自定义图像。 你的代码在这里
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="your_custom_image"
android:gravity="center"
android:orientation="vertical"
android:padding="20dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="text_goes_here"
android:textColor="specify_color" />
</LinearLayout>
【讨论】: