简体   繁体   中英

CheckBox widget in the top right corner of an image

Currently I am downloading 2 images per row via Picasso. I'd want to add a CheckBox in the top right corner of each of them. How should the checkbox be defined? Here is the layout so far:

<!--Row1-->
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dip"
    android:orientation="horizontal"
    android:layout_weight="1">

        <ImageView
            android:id="@+id/img1"
            style="@style/singleImage"
            android:layout_marginRight="10dp"/>


        <ImageView
            android:id="@+id/img2"
            style="@style/singleImage"/>
</LinearLayout>

And the style:

<style name="singleImage">
    <item name="android:layout_width">0dp</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_weight">1</item>
</style>

My comment its mean like this:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dip"
    android:layout_weight="1"
    android:orientation="horizontal">

    <RelativeLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1">

        <ImageView
            android:id="@+id/img1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginRight="10dp" />

        <CheckBox
            android:id="@+id/checkBox1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:text="" />
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1">

        <ImageView
            android:id="@+id/img2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginRight="10dp"
            android:layout_weight="1" />

        <CheckBox
            android:id="@+id/checkBox2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:text="" />
    </RelativeLayout>
</LinearLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM