[英]Why don't work Gravity center for Check Box
我有一個復選框並設置重心,但該框沒有居中
這是我的 XML 文件
<CheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="8dp"
android:gravity="center"
android:checked="false"
android:clickable="false"
app:buttonTint="@color/colorPrimary"
android:scaleX="1.4"
android:scaleY="1.4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
復選框圖像:
我自己用風格解決了這個問題
首先設置style屬性
android:theme="@style/checkBoxStyle"
創建風格
<style name="checkBoxStyle" parent="Base.Theme.AppCompat">
<item name="colorAccent">@color/colorPrimary</item>
<item name="android:textColorSecondary">@color/colorPrimary</item>
</style>
ConstraintLayout Chains Android 開發人員最近發布了新版本的 ConstraintLayout(截至今日為 1.0.2)。 這個版本包含一個新的主要特性——鏈,它允許我們在 ConstraintLayout 中對視圖進行分組。
鏈在單個軸(水平或垂直)上提供類似組的行為。
如果一組小部件通過雙向連接鏈接在一起,則它們被視為鏈
創建鏈后,有兩種可能性:
在可用空間中展開元素 鏈也可以“打包”,在這種情況下,元素被組合在一起
也許我弄錯了,但我對單選按鈕進行了同樣的嘗試,它只將與單選按鈕關聯的文本居中。 但我想你可能會在這里找到答案: https://stackoverflow.com/questions/47386980/align-checkbox-to-center-of-the-listview-item/47387075#:~:text=Create%20a% 20LinearLayout%20as%20PARENT.&text=如果%20you%20check%20the%20device,它%20should%20work 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.