質問

I'm developing an Android app and I want to create a TableLayout with a white background and a background image aligned at the top left, because is a 'bend effect'.

This is the top left image:

bend effect

I defined the TableLayout like this:

<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" >

But I don't know how to put the image at the top left, or if background images are compatible with background colors or if there is a better way to do this thing...

役に立ちましたか?

解決

The best way to define where the image will go is to use an Imageview inside that layout. You can define placement of the image by using android:gravity

他のヒント

You can achieve the bend effect using ImageView where the White color will be background and the image will be set as src as below...

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

Finally I insert an ImageView inside the TableRow

<!-- 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>

And works ok. Thanks.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top