English 中文(简体)
Android: 如何在表格布局中设置背景图像
原标题:Android: how to set background image in table layout

Im using tablelayout to display items from sqlite db. I set a backgrpund image for table layout, but the image appears below the texts I need to display the image back to the texts, not below,ie, I need the image frame as 0,0 What I have to do . Now I used

.setbackgroundresources(r.drawable.imagename)

请指导我,我必须用程序化的桌面布局添加背景图像

问题回答

如果您重新为布局设置背景资源, 图像会出现在布局本身( 在所有组件下方) 下, 您可能不会将背景资源添加到正确的布局中 。

但既然你没有真正提供多少信息 情况可能就不是这样了

你的形象是否真的比桌子本身小得多, 而不是扩大到桌子的大小, 能否保持固定的大小( 可能以布局为中心)?

尝试将表格的背景设置为固定的颜色( 即视图. setBackroundColor( 彩色. BLACK) ) 来测试这一点。 如果整个表格填满了您所期望的, 那么它很可能与您正在使用的图像相关 。

如果颜色只填充图像资源之前的相同区域, 那么这可能是我第一次想到您不将资源添加到正确布局的地方 。

然后尝试将表格布局的外部布局线性布局放在. xml 文件中,然后将线性布局的背景设置为类似

<LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/bkg1">

 <TableLayout
                android:id="@+id/linearLayout1_tblLayout1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <TableRow
                    android:id="@+id/linearLayout1_tblLayout1_tableRow1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center" >


                    ......

                   </TableRow>

</TableLayout>
</LinearLayout>




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签