3,4,...9
在标准的sans-serif字体中。除了线性布局的范围内,还有一个图像视图,还有一个包含字母M
视图的目的是让用户通过用手指调整图像视图的长度来选择数字范围。以下是模拟器上的外观,例如在小米Hyperos上:
这就是三星Galaxy 33a上的样子。数字没有显示:有人知道三星设备的特定错误吗?解决此类问题的建议是什么?感谢您的任何建议。 布局的xml xode:
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/plageEtCartouche"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="16dp">
<LinearLayout
android:id="@+id/plageNombreLettres"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:elevation="5dp"
android:gravity="start"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/tv3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="1"
android:gravity="center"
android:includeFontPadding="false"
android:text="3"
android:textColor="@android:color/black"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="1"
android:gravity="center"
android:includeFontPadding="false"
android:text="4"
android:textColor="@android:color/black"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="1"
android:gravity="center"
android:includeFontPadding="false"
android:text="5"
android:textColor="@android:color/black"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="1"
android:gravity="center"
android:includeFontPadding="false"
android:text="6"
android:textColor="@android:color/black"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="1"
android:gravity="center"
android:includeFontPadding="false"
android:text="7"
android:textColor="@android:color/black"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="1"
android:gravity="center"
android:includeFontPadding="false"
android:text="8"
android:textColor="@android:color/black"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="1"
android:gravity="center"
android:includeFontPadding="false"
android:text="9"
android:textColor="@android:color/black"
android:textSize="24sp"
android:textStyle="bold" />
</LinearLayout>
<ImageView
android:id="@+id/cartouche"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginEnd="160dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/cartouche" />
<TextView
android:id="@+id/btnMono"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="1"
android:fontFamily="cursive"
android:gravity="center"
android:includeFontPadding="false"
android:text="M"
android:textColor="@android:color/black"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/plageNombreLettres"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
腐烂
顺便说一句,在片段中,有几行代码来调整文本视图的大小和图像视图以适合屏幕的大小:
private fun initConstraints() {
pasNombre = (largeurEcran - 56.dp) / 10
for (view in binding.plageNombreLettres) {
view.updateLayoutParams<LinearLayout.LayoutParams> {
width = pasNombre
}
}
binding.plageEtCartouche.updateLayoutParams<LinearLayout.LayoutParams> {
height = pasNombre
}
val startCons = filtre.lMin.start
val endCons = filtre.lMax.end
binding.cartouche.updateLayoutParams<ConstraintLayout.LayoutParams> {
marginStart = startCons
marginEnd = endCons
}
}
我通过回到以前有效的先前版本来解决问题:我将
M
文本视图放入线度读词中,每一侧都有一个空的文本视图(将其集中在剩余空间中而不扩展它) .
我还必须更新循环以缩小片段中的数字。 现在它也适用于三星银河系。不要问我为什么!
我必须说,我还升级了不是最新的一些依赖项,例如:IMplementation(“ Androidx.constraintlayout:ConstraintLayout:2.2.0”)
build.gradle.kts
碎片中的循环
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/plageEtCartouche"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="16dp">
<LinearLayout
android:id="@+id/plageNombreLettres"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:elevation="5dp"
android:gravity="start"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/tv3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="1"
android:gravity="center"
android:includeFontPadding="false"
android:text="3"
android:textColor="@android:color/black"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="1"
android:gravity="center"
android:includeFontPadding="false"
android:text="4"
android:textColor="@android:color/black"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="1"
android:gravity="center"
android:includeFontPadding="false"
android:text="5"
android:textColor="@android:color/black"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="1"
android:gravity="center"
android:includeFontPadding="false"
android:text="6"
android:textColor="@android:color/black"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="1"
android:gravity="center"
android:includeFontPadding="false"
android:text="7"
android:textColor="@android:color/black"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="1"
android:gravity="center"
android:includeFontPadding="false"
android:text="8"
android:textColor="@android:color/black"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="1"
android:gravity="center"
android:includeFontPadding="false"
android:text="9"
android:textColor="@android:color/black"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/empty1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="1"
android:gravity="center"
android:includeFontPadding="false"
android:textColor="@android:color/black"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/btnMono"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="1"
android:fontFamily="cursive"
android:gravity="center"
android:includeFontPadding="false"
android:text="M"
android:textColor="@android:color/black"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/empty2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="1"
android:gravity="center"
android:includeFontPadding="false"
android:textColor="@android:color/black"
android:textSize="24sp"
android:textStyle="bold" />
</LinearLayout>
<ImageView
android:id="@+id/cartouche"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginEnd="160dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/cartouche" />
</androidx.constraintlayout.widget.ConstraintLayout>