2017-03-10 4 views

Antwort

1

die Sie interessieren,

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 


     <RelativeLayout 
      android:id="@+id/relativeLayout" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_margin="10dp"> 

      <Button 
       android:id="@+id/button" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:padding="10dp" 
       android:text="Keyword Title 1" /> 

     </RelativeLayout> 

     <CheckBox 
      android:layout_width="20dp" 
      android:layout_height="20dp" 
      android:layout_alignEnd="@+id/relativeLayout" 
      android:layout_alignTop="@+id/relativeLayout" /> 


    </RelativeLayout> 
+0

Ich habe diese Methode versucht, aber das Kontrollkästchen wird hinter der Schaltfläche angezeigt –

+0

@ PrabhaKaran Sorry für späte Wiedergabe .. Ihr Problem gelöst? – user2025187

+0

Mein Problem gelöst, ich habe die Idee –

1

unten Code Bitte folgen Sie res/layout/MainLayout.xml:

<FrameLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 
     <TextView 
      android:text="@string/keyword_title_1" 
      android:id="@+id/section_label" 
      android:padding="8dp" 
      android:layout_margin="8dp" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@drawable/textview_background"/> 
     <CheckBox 
      android:button="@drawable/checkbox_selector" 
      android:layout_gravity="top|end" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 
    </FrameLayout> 

res/drawable/textview_background.xml:

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <solid android:color="@color/white"/> 
    <stroke android:color="@color/black" android:width="1dp"/> 
</shape> 

res/drawable/checkbox_selector.xml:

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android" > 
    <item android:drawable="@drawable/checkbox" 
      android:state_checked="false"/> 
    <item android:drawable="@drawable/checkboxselected" 
      android:state_checked="true"/> 
    <item android:drawable="@drawable/checkbox"/>  
</selector> 
Verwandte Themen