我使用带有预设 TabItems 的 ViewPager2 和 TabLayout 进行了简单设置:
...
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
android:layout_width="0dp"
android:layout_height="64dp"
app:tabTextColor="@color/c0696D7"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/palettesToggle"
app:layout_constraintTop_toTopOf="parent"
app:tabBackground="@color/cEEEEEE"
app:tabIndicatorColor="@color/cFFFFFF"
app:tabGravity="fill"
app:tabUnboundedRipple="true"
app:tabIconTint="@color/palettes_icon_tint"
app:tabIndicatorGravity="stretch"
app:tabMode="fixed">
<com.google.android.material.tabs.TabItem android:icon="@drawable/palettes_layers" />
<com.google.android.material.tabs.TabItem android:icon="@drawable/palettes_view" />
<com.google.android.material.tabs.TabItem android:icon="@drawable/palettes_properties" />
<com.google.android.material.tabs.TabItem android:icon="@drawable/palettes_blocks" />
<com.google.android.material.tabs.TabItem android:icon="@drawable/palettes_blocks" />
<com.google.android.material.tabs.TabItem android:icon="@drawable/palettes_settings" />
</com.google.android.material.tabs.TabLayout>
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tabs" />
...
Run Code Online (Sandbox Code Playgroud)
以及以下接线代码:
TabLayoutMediator(tabs, viewPager) { tab, position ->
}.attach()
Run Code Online (Sandbox Code Playgroud)
以下设置忽略了TabItemicon 属性,我看到了空标签。似乎TabLayoutMediator完全覆盖了定义的 xml 属性,我必须将这些属性重置为TabConfigurationStrategy回调的一部分。我错过了什么吗?
android android-tablayout material-components-android android-viewpager2
我想使用提到的插件与声明性管道,准确地说,我想将以下文档示例转换为声明性管道:
上游作业中的管道代码如下:
stage ('Stage 1. Allocate workspace in the upstream job')
def extWorkspace = exwsAllocate 'diskpool1'
node ('linux') {
exws (extWorkspace) {
stage('Stage 2. Build in the upstream job')
git url: 'https://github.com/alexsomai/dummy-hello-world.git'
def mvnHome = tool 'M3'
sh '${mvnHome}/bin/mvn clean install -DskipTests'
}
}
Run Code Online (Sandbox Code Playgroud)
下游的Pipeline代码是:
stage ('Stage 3. Select the upstream run')
def run = selectRun 'upstream'
stage ('Stage 4. Allocate workspace in the downstream job')
def extWorkspace = exwsAllocate selectedRun: run
node ('test') {
exws (extWorkspace) {
stage('Stage 5. …Run Code Online (Sandbox Code Playgroud) 我正在使用首选项库(androidx.preference:preference)以及材质组件主题(Theme.MaterialComponents.Light.DarkActionBar)。我正在寻找一种正确的方法来设置类别文本的样式(字体、大小、颜色)(不更改整个布局)以及首选项文本本身。官方首选项库示例展示了一种在字符串资源内使用 HTML 标签显示样式首选项的方法,但我正在寻找一种通过主题更改它(和标题)的方法:
android android-theme android-styles preferencefragment material-components-android
我有一个简单的设置:
lifecycleScope.launch {
val result = test()
}
suspend fun test(): Result<Unit> = withContext(Dispatchers.IO) {
Result.failure(IllegalStateException("QWER"))
}
Run Code Online (Sandbox Code Playgroud)
实际结果: 上面的代码崩溃了:java.lang.IllegalStateException: QWER
预期结果: 结果对象按预期返回
我使用 kotlin 1.4.10 和协程 1.3.9。我使用 kotlin.Result 对象作为返回类型,为此我有:
kotlinOptions {
freeCompilerArgs = ["-Xallow-result-return-type"]
}
Run Code Online (Sandbox Code Playgroud)
另一件事是,如果我使用主上下文 (Dispatchers.Main) 执行协程,一切都会按预期进行。
我在我的应用程序中使用了image-chooser-library,其中定义了android:icon所以我需要覆盖此属性以便gradle成功构建:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.sample.sample">
<application
android:icon="@drawable/icon"
tools:replace="icon"/>
</manifest>
Run Code Online (Sandbox Code Playgroud)
但我仍然得到以下内容:
清单合并失败:来自AndroidManifest.xml的属性应用程序@ icon value =(@ drawable/icon):com.kbeanie中也存在20:9:image-chooser-library:1.4.3:13:9 value =(@ drawable/ic_launcher)建议:在AndroidManifest.xml:15:5中添加'tools:replace ="android:icon"'到元素
有什么建议?
android android-manifest android-studio android-gradle-plugin