英文:
Why when dragging each time a Widgets SeekBar it's giving it higher number name and also give error in android studio?
问题
The seekbar after dragged it in the designer the bottom left show seekbar6 and also error that missing Constraints.
and when switching to code I'm getting error on the SeekBar:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<SeekBar
android:id="@+id/seekBar6"
android:layout_width="377dp"
android:layout_height="18dp"
tools:layout_editor_absoluteX="21dp"
tools:layout_editor_absoluteY="355dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
I tried in the designer to delete many times but it keeps adding a new seekbar with higher names like seekbar6, then seekbar7, and not just SeekBar and keeps giving these errors.
英文:
The seekbar after dragged it in the designer the bottom left show seekbar6 and also error that missing Constraints.
and when switching to code I'm getting error on the SeekBar:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<SeekBar
android:id="@+id/seekBar6"
android:layout_width="377dp"
android:layout_height="18dp"
tools:layout_editor_absoluteX="21dp"
tools:layout_editor_absoluteY="355dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
I tried in the designer to delete many times but it keep adding new seekbar with higher name like seekbar6 then seekbar7 and not just SeekBar
and keep giving these errors.
答案1
得分: 1
我在xml中复制了你的代码,同样在开头遇到了一个约束错误消息。
所以,我手动添加了约束条件:
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent"
我还执行了一次Clean Project,然后进行了一次Rebuild Project。
我附上了我创建的布局的代码和图片。
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<SeekBar
android:id="@+id/seekBar6"
android:layout_width="377dp"
android:layout_height="18dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
希望这对你的问题有所帮助
英文:
I replicated your code in an xml, and in the same way at the beginning I got a constraint error message.
So, I added the Constraints manually
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent"
And also I did a Clean Project and then a Rebuild Project.
I attach the code and image of the layout that I made.
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<SeekBar
android:id="@+id/seekBar6"
android:layout_width="377dp"
android:layout_height="18dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Hope I helped with your problem
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论