2016-02-27 40 views
1

我想創建一個複選框,以在我的android應用程序中選擇顏色。然而複選框出現在最左邊的中心。如何將其定位在右上角? This is how I get位置複選框到右上角

+2

發佈您試過的代碼 – user5894647

+1

要使用哪種佈局,發佈佈局文件以便我們可以看一看 – user5894647

+0

我使用的是有4個複選框的tablerow。複選框已正確創建。但實際上被檢查的小盒子出現在左邊的中心。相反,當我們從圖庫中選擇圖像時,通常會出現在右上角。 –

回答

0

試試這個:

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 
    <CheckBox 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@drawable/red_button" 
     android:layout_weight="1" 
     android:id="@+id/red1" 
     android:layout_marginLeft="5dp" 
     android:layout_marginRight="5dp" 
     android:checked="false" 
     android:gravity="right" /> 

</LinearLayout> 

希望它可以幫助!