2014-03-06 52 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> 

而且工作正常。謝謝。