我试图将两个按钮放置在约束布局的底部。在 Android Studio 的设计视图中,一切看起来都不错,但是当我在调试中运行应用程序时,按钮看起来像是与屏幕顶部的最后一个字段对齐。我已经尝试过指南和障碍,但无法让障碍在我的工作室版本(3.0.1)中工作。如果我尝试按下显示屏顶部的按钮,当我切换到横向模式时它们就会消失。有什么建议,或者我应该在这个问题上采用另一种类型的布局吗?谢谢
我的设计图

我的代码:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
android:id="@+id/location_detail"
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="match_parent"
android:fitsSystemWindows="true">
<android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="10dp"
app:layout_constraintHeight_min="?attr/actionBarSize"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/location_name_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:labelFor="@+id/location_name"
android:text="@string/location_name_title"
app:layout_constraintBaseline_toBaselineOf="@+id/location_name"
app:layout_constraintLeft_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/guideline"/>
<EditText
android:id="@+id/location_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:ems="13"
android:inputType="textPersonName"
app:layout_constraintLeft_toRightOf="@+id/guideline2"
app:layout_constraintTop_toBottomOf="@+id/guideline"/>
<TextView
android:id="@+id/location_region_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/location_region_title"
app:layout_constraintBaseline_toBaselineOf="@+id/location_region"
app:layout_constraintLeft_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/location_name_title"/>
<TextView
android:id="@+id/location_region"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/location_detail_region"
app:layout_constraintLeft_toRightOf="@+id/guideline2"
app:layout_constraintTop_toBottomOf="@+id/location_name"/>
<TextView
android:id="@+id/location_country_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/location_country_title"
app:layout_constraintBaseline_toBaselineOf="@+id/location_country"
app:layout_constraintLeft_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/location_region_title"/>
<TextView
android:id="@+id/location_country"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/location_detail_country"
app:layout_constraintLeft_toRightOf="@+id/guideline2"
app:layout_constraintTop_toBottomOf="@+id/location_region"/>
<TextView
android:id="@+id/location_latitude_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/location_detail_latitude" …Run Code Online (Sandbox Code Playgroud) 我已经将 WorkManagerUUID转换为StringRealm 数据库。
这是代码 -
Constraints constraints = new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build();
Data inputData = new Data.Builder().putString("downloadUrl", downloadUrl).
putString("destinationFolder", destinationFolder).
putInt("suraNumber", Integer.parseInt(suraNumber)).
putString("fileName", fileName).
putBoolean("downloadFileTypeBangla", downloadFileTypeBangla).
putBoolean("downloadFileTypeArabic", downloadFileTypeArabic).
putBoolean("downloadFileTypeArabicWithBangla", downloadFileTypeArabicWithBangla).build();
OneTimeWorkRequest downloadWork = new OneTimeWorkRequest.Builder(DownloadWorker.class).setConstraints(constraints).setInputData(inputData).build();
WorkManager.getInstance().enqueue(downloadWork);
Sura sura = dbOperations.getSuraById(Integer.parseInt(suraNumber));
if(sura != null){
dbOperations.updateSura(sura, Integer.parseInt(suraNumber), sura.getBnAudioDownloadStatus(), sura.getArAudioDownloadStatus(), 1);
realm.beginTransaction();
DownloadStatusModel downloadStatusModel = new DownloadStatusModel();
downloadStatusModel.setId(new RealmCommonService(realm).newId(DownloadStatusModel.class));
downloadStatusModel.setDownloadFileType("ArabicWithBangla");
downloadStatusModel.setActiveStatus(true);
downloadStatusModel.setDownloadDate(new Date());
downloadStatusModel.setDownloadedSuraNo(sura.getSuraNo());
downloadStatusModel.setDownloadFileSize(sura.getArBnAudioFileSize());
downloadStatusModel.setDownloadReferenceId(downloadWork.getId().toString());
downloadStatusModel.setDownloadedSuraNameBangla(sura.getSuraNameBangla());
downloadStatusModel.setDownloadStatus(1);
realm.copyToRealm(downloadStatusModel);
realm.commitTransaction();
}
Run Code Online (Sandbox Code Playgroud)
现在我试图取消Work使用这行代码,但没有奏效。
WorkManager.getInstance().cancelWorkById(UUID.fromString(downloadStatusModel.getDownloadReferenceId()));
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激
谢谢