Align text left, checkbox right

前端 未结 13 2454
孤街浪徒
孤街浪徒 2020-12-29 18:28

I\'m trying to create a layout for a ListView, with a checkbox to the right and some text to the left. The checkbox should be aligned all the way to the right and the TextV

13条回答
  •  盖世英雄少女心
    2020-12-29 19:01

    After trying to do this myself, I finally did it. You just need to put a TextView and a CheckBox in a horizontal layout, and put the gravity on the layout to the right.

    Here's the code:

    
    
    
    
    

    EDIT: I just noticed that you wanted text all the way to the left side of the screen. this will put the check box all the way to the right, and the text right next to it on the left side of the check box.

    Like this:

    ------------------------
               text checkbox
    ------------------------
               text checkbox
    ------------------------
               text checkbox
    ------------------------
    

提交回复
热议问题