首页 > 解决方案 > 有没有办法将复选框图标及其文本移动到屏幕中心

问题描述

滚动屏幕前的图像

滚动屏幕后的图像

  <CheckBox
    android:id="@+id/cb_whatsapp_consent"
    android:layout_width="wrap_content"
    android:layout_height="@dimen/button_height"
    android:layout_marginTop="@dimen/size_16dp"
    android:background="@color/white"
    android:checked="true"
    android:text="@string/get_updates_and_reminders_on"
    android:textColor="@color/grey_text"
    android:textSize="@dimen/text_size_small"
    android:visibility="visible"
    tools:visibility="visible"
    android:layout_gravity="bottom|center"
    android:gravity="center"
    android:layout_marginBottom="80dp"/>** I have tried by adding layout_width as match_parent but in that case only the text moves to centre and the checkbox still remains to left(Screenshot added with name as [Screen when layout_width is given as match_parent and scrolled][3]match_parent). I have alsotried by adding the padding, But the padding gets applied only to text. **

标签: androidcheckbox

解决方案


在约束布局中使用: starttostartof="parent" endtoendof="parent"


推荐阅读