我想在CardView上做透明的背景.我知道backgroundColor,但我的布局上有图像.
你知道怎么做吗?或者作为cardview的东西,但我会设置一个透明的背景?
问候
我正在使用 Jetpack Compose 创建一个布局,并且有一列。我想要此列中的中心项目:
Column(modifier = ExpandedWidth) {
Text(text = item.title)
Text(text = item.description)
}
Run Code Online (Sandbox Code Playgroud) 我希望使用OkHttp进行Retrofit,当没有Internet时使用缓存.
我准备OkHttpClient是这样的:
RestAdapter.Builder builder= new RestAdapter.Builder()
.setRequestInterceptor(new RequestInterceptor() {
@Override
public void intercept(RequestFacade request) {
request.addHeader("Accept", "application/json;versions=1");
if (MyApplicationUtils.isNetworkAvaliable(context)) {
int maxAge = 60; // read from cache for 1 minute
request.addHeader("Cache-Control", "public, max-age=" + maxAge);
} else {
int maxStale = 60 * 60 * 24 * 28; // tolerate 4-weeks stale
request.addHeader("Cache-Control",
"public, only-if-cached, max-stale=" + maxStale);
}
}
});
Run Code Online (Sandbox Code Playgroud)
并像这样设置缓存:
Cache cache = null;
try {
cache = new Cache(httpCacheDirectory, 10 * 1024 * 1024);
} catch …Run Code Online (Sandbox Code Playgroud) 如何为 Android 单元测试配置 JUnit 5?我试过:
testCompile("org.junit.jupiter:junit-jupiter-api:5.0.0")
Run Code Online (Sandbox Code Playgroud)
但它不起作用,当我运行以前最简单的单元测试时:
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
Run Code Online (Sandbox Code Playgroud)
我得到错误:
Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform.commons.util.ReflectionUtils.getDefaultClassLoader()Ljava/lang/ClassLoader;
at org.junit.platform.launcher.core.ServiceLoaderTestEngineRegistry.loadTestEngines(ServiceLoaderTestEngineRegistry.java:31)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:42)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:36)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Process finished with exit code 1
Empty test suite.
Run Code Online (Sandbox Code Playgroud)