如何查看动态创建的TextView的setBackgroundResource()的xml文件?

时间:2012-01-06 16:22:50

标签: android android-layout android-widget

我在代码中创建应用程序GUI(没有布局xml文件)。 java代码是:

TextView tv = new TextView (this);
tv.setBackgroundResource (R.drawable.custom_tv);

我不知道该怎么看这个custom_tv.xml文件。 我试着以这样的方式写它:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <ScrollView android:id="@+id/chat_ScrollView"
           android:layout_width="fill_parent" 
           android:layout_height="fill_parent"
           android:layout_alignParentRight="true"
           android:layout_alignParentLeft="true">

           <TextView android:id="@+id/chat_text_chat"
              android:text="center chat" 
              android:layout_width="fill_parent" 
              android:layout_height="fill_parent"
              android:singleLine="false" />
        </ScrollView>
   </item>
</layer-list>

但它没有用。那么,应该怎么看这个xml文件?感谢。

1 个答案:

答案 0 :(得分:0)

我不太清楚你为什么要使用ScrollView这样做,假设你每次都添加多个textview?用一个textview替换scrollview并在需要时更改文本不是更好吗?