小编Ami*_*dat的帖子

CardView 位于 Recycler 视图上方,滚动为一个

我试图将卡片视图放置在回收者视图上方。我想将我的卡片视图和回收器视图作为一个滚动。问题是,只有回收器视图在滚动,并且回收器视图的内容在大小上相当扭曲。这就是我想要实现的目标: 示例图像

这是我的 xml:

<android.support.constraint.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/frameLayout3"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".HomeFragment">

<!-- TODO: Update blank fragment layout -->

<android.support.v7.widget.CardView

    android:id="@+id/cardView"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:isScrollContainer="false"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginEnd="9dp"
        android:src="@drawable/background"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.v7.widget.CardView>


<android.support.v7.widget.RecyclerView
    android:id="@+id/blogListView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    app:layout_constraintTop_toBottomOf="@+id/cardView" />
Run Code Online (Sandbox Code Playgroud)

将不胜感激任何建议。

java xml android android-recyclerview

2
推荐指数
1
解决办法
1508
查看次数

在 android 应用发布版本中获取错误的版本代码和版本名称

我使用下面的代码在 MyApplication 类中以编程方式获取版本名称和版本代码,并将它们声明为静态成员

public class MyApplication extends Application {
   Public static String MY_VERSION_NAME;
   Public static int MY_VERSION_NAME;  
    @Override
    public void onCreate() {
       getPackageInfo();
    }  
    private void getPackageInfo() {
        Context context = getApplicationContext();
        PackageManager manager = context.getPackageManager();
        try {
            PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
            MY_VERSION_NAME = info.versionName;
            MY_VERSION_CODE = (int) PackageInfoCompat.getLongVersionCode(info);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
            myversionName = "Unknown-01";
        }
   } 
}
Run Code Online (Sandbox Code Playgroud)

我的应用程序gradle文件是:

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
    applicationId "com.example"
    minSdkVersion 19 
    targetSdkVersion 28
    versionCode 15
    versionName …
Run Code Online (Sandbox Code Playgroud)

android gradle

1
推荐指数
1
解决办法
1929
查看次数

标签 统计

android ×2

android-recyclerview ×1

gradle ×1

java ×1

xml ×1