将复选框定位到右上角



我想创建一个复选框来在我的安卓应用程序中选择颜色。但是,该复选框显示在最左侧的中心。如何将其放置在右上角?这就是我得到的方式

试试这个:

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

希望对您有所帮助!!

最新更新