我正在制作带有照片的水平RecyclerView,我遇到了wrap_parent问题.如果我放入我的View width = wrap_content,它是screenWidth宽度,虽然图像消耗非常小的空间.如果我wrap_content改为某个值,它就可以完美地工作.RcyclerView的高度为75dp match_parent.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:clickable="true"
android:foreground="@drawable/card_foreground">
<ImageView
android:id="@+id/bitmap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/image" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
深蓝色是屏幕,浅蓝色是照片.问题是当我设置视图时,我有案例1 wrap_content.
解:
我最近解决了这个问题,当你尝试使用缩放的ImageView wrap_parent时,有一些bug或类似的东西.它不能很好地工作.为了解决这个问题,我已将每张照片调整为最终尺寸,然后再将其放入RecyclerView.另外,我再次在ImageView之间留下了一些小空间,我通过添加padding=0和margin=0回收的RecyclerView来解决这个问题.
我正在尝试将hello-jni示例实现
到我的项目中.我有Gradle2.8 'com.android.tools.build:gradle-experimental:0.4.0'和使用Android Studio 2.0 Preview 3b.
这是我的build.gradle:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"
defaultConfig.with {
applicationId = "lala.lala"
minSdkVersion.apiLevel = 16
targetSdkVersion.apiLevel = 23
versionCode = 1
versionName = "1.0"
}
}
/*
* native build settings
*/
android.ndk {
moduleName = "hello-jni"
// cppFlags.add("-fno-rtti")
// cppFlags.add("-fno-exceptions")
// ldLibs.addAll(["android", "log"])
// stl = "system"
}
android.productFlavors {
// for detailed abiFilter descriptions, …Run Code Online (Sandbox Code Playgroud)