2016-10-19 35 views
0

目前我正在通過Picasso每行下載2張圖像。我想在每個人的右上角添加一個複選框。該複選框應該如何定義?這裏是佈局至今:圖像右上角的CheckBox小部件

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

而且款式:

<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> 
+0

首先,你在你的佈局添加2複選框,然後使用RelativeLayout的分組(ImageView_1和CheckBox_1)&(ImageView_2和CheckBox_2) – Sodiq

+0

Okey,但如何對齊它們並使它們出現在圖像上?遵照你的建議,他們只是簡單地替換圖像。 – user6456773

+0

' <複選框 機器人:ID = 「@ + ID/checkBox1」 機器人:layout_width = 「WRAP_CONTENT」 機器人:layout_height =「WRAP_CONTENT 「 機器人:layout_alignParentRight =」 真」 機器人:layout_alignParentTop = 「真」 機器人:文本= 「」/> ' – Sodiq

回答

2

我的評論它的意思是這樣:

<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> 
+0

哦,現在我明白了!非常感謝,太棒了! – user6456773

+0

歡迎您... – Sodiq

相關問題