约束布局中的平均比率的分割视图

时间:2017-11-10 08:11:27

标签: android xml android-layout android-constraintlayout

目前,我有一个使用constraintLayout的布局,如下所示

如您所见,我使用垂直指南将每个部分中的checkbox除以10%宽度。但是,由于用户请求,checkedboxs的总和将会更改。这意味着它可以在一行中显示4或3 checkbox

此时,我想将宽度除以重量而不是设置硬编码百分比。我应该为此做些什么?

感谢任何评论或建议。谢谢

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/worklist_normal_row_bg">

    <TextView
        android:id="@+id/textView97"
        style="@style/label_txt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:layout_marginStart="8dp"
        android:text="TextView"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginLeft="8dp" />

    <TextView
        android:id="@+id/textView102"
        style="@style/label_txt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="32dp"
        android:layout_marginStart="8dp"
        android:text="TextView"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView97"
        android:layout_marginLeft="8dp" />

    <TextView
        android:id="@+id/textView103"
        style="@style/label_txt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView"
        app:layout_constraintStart_toEndOf="@+id/textView102"
        app:layout_constraintTop_toTopOf="@+id/textView97"/>

    <TextView
        android:id="@+id/textView104"
        style="@style/label_txt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:text="TextView"
        android:textSize="14sp"
        app:layout_constraintBaseline_toBaselineOf="@+id/textView102"
        app:layout_constraintStart_toStartOf="@+id/guideline12"
        android:layout_marginLeft="8dp" />

    <CheckBox
        android:id="@+id/checkBox2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="20dp"
        android:text=" "
        app:layout_constraintBaseline_toBaselineOf="@+id/textView103"
        app:layout_constraintStart_toStartOf="@+id/guideline12"
        tools:checked="true" />

    <CheckBox
        android:id="@+id/checkBox4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=" "
        app:layout_constraintBaseline_toBaselineOf="@+id/checkBox2"
        app:layout_constraintStart_toEndOf="@+id/checkBox2"
        tools:checked="true" />

    <CheckBox
        android:id="@+id/checkBox5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=" "
        app:layout_constraintBaseline_toBaselineOf="@+id/checkBox4"
        app:layout_constraintStart_toEndOf="@+id/checkBox4"
        tools:checked="true" />

    <CheckBox
        android:id="@+id/checkBox6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=" "
        app:layout_constraintBaseline_toBaselineOf="@+id/checkBox5"
        app:layout_constraintStart_toEndOf="@+id/checkBox5"
        tools:checked="true" />

    <CheckBox
        android:id="@+id/checkBox7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=" "
        app:layout_constraintBaseline_toBaselineOf="@+id/checkBox6"
        app:layout_constraintStart_toEndOf="@+id/checkBox6"
        tools:checked="true" />

    <TextView
        android:id="@+id/textView105"
        android:layout_width="0dp"
        android:layout_height="2dp"
        android:layout_marginTop="8dp"
        android:background="@color/worklist_divider_bg"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView104" />

    <android.support.constraint.Guideline
        android:id="@+id/guideline11"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_percent="0.3" />

    <android.support.constraint.Guideline
        android:id="@+id/guideline12"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_percent="0.5" />

</android.support.constraint.ConstraintLayout>

Result view

1 个答案:

答案 0 :(得分:1)

试试这个。

DELETE FROM [TableA]
WHERE ColumnA IN (SELECT Id FROM DeleteTarget)

DELETE FROM [TableB]
WHERE ColumnB IN (SELECT Name FROM DeleteTarget)