2014-03-06 75 views
2

我正在开发一个Android应用程序,我想创建一个带有白色背景和背景图像的左上角的TableLayout,因为这是一种“弯曲效果”。TableLayout中的背景图像和背景颜色

这是左上角的图像:

bend effect

我定义的TableLayout是这样的:

<TableLayout 
    android:id="@+id/tableLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_marginBottom="16dp" 
    android:layout_marginLeft="16dp" 
    android:layout_marginRight="16dp" 
    android:layout_marginTop="16dp" 
    android:background="@color/white" > 

但我不知道如何把图像左上角,或者如果背景图像与背景颜色兼容,或者如果有更好的方法来做这件事...

+0

您只能拥有1个背景。在颜色,图像或绘图之间进行选择。 –

回答

1

定义图像的最佳方式将会去在该布局中使用Imageview。您可以通过使用Android的定义图像的位置:重力

1

可以实现使用ImageView弯曲效果,其中白色将是背景和图像将被设置为src如下...

<ImageView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@color/white" 
    android:src="@drawable/image" /> 
0

最后我在TableRow里插入一个ImageView

<!-- 2 columns --> 
    <TableRow 
     android:id="@+id/tableRow1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
      > 
    <!-- top left bend --> 
    <ImageView 
     android:layout_gravity="left|top" 
     android:adjustViewBounds="true" 
     android:background="@drawable/top_left_corner_bend" 
     android:contentDescription="@string/email" 
    /> 
    <!-- top left bend --> 
    </TableRow> 

而且工作正常。谢谢。