我有一个RecyclerView里面的HorizontalScrollView. 我没有看到RecyclerView所有项目的内部。我看过了,即使适配器中的列表有 7 个项目,onBindViewHolder也只调用了 4 次!如果我取出HorizontalScrollView,它工作正常。
我使用 是HorizontalScrollView因为我需要在回收的背景下滚动列表,而不是在回收内,它通常是如何工作的。
所以,我需要一个解决方案来滚动带有列表背景的列表,或者使用 HorizontalScrollView
更新 :
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="20dp">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:scrollbars="none"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/label">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/rlWrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/paddingStartView"
android:background="@drawable/bg_round_corner">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/optionsRv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent" />
</RelativeLayout>
<View
android:id="@+id/paddingStartView"
android:layout_width="16dp"
android:layout_height="16dp" />
<View
android:id="@+id/paddingEndView"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_toEndOf="@id/rlWrapper" />
</RelativeLayout>
</HorizontalScrollView>
<TextView
android:id="@+id/label"
style="@style/FontLocalizedMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:textAllCaps="true"
android:textColor="#979797"
android:textSize="12sp" …Run Code Online (Sandbox Code Playgroud) 我有毕加索图书馆的问题.
我有一个带有View Pager的导航抽屉,在View Pager中我从drawable文件夹加载图像.
我有一个像这样的字符串数组
public static final String [] IMAGES =
{
"drawable://" + R.drawable.aa12,
"drawable://" + R.drawable.acr,
"drawable://" + R.drawable.ai_l96a1,
etc.
}
Run Code Online (Sandbox Code Playgroud)
这就是我尝试加载图片的方式:
Picasso.with(mContext).load(Constants.IMAGES[position]).placeholder(R.drawable.ic_stub).into(imageView);
Run Code Online (Sandbox Code Playgroud)
问题是在我的ViewPager中它只显示ic_stub图像.
有人知道为什么吗?
我想编译com.squareup.picasso:picasso:2.5.3-SNAPSHOT.但我得到了这个错误:
Error:Could not find com.squareup.picasso:picasso:2.5.3-SNAPSHOT.
Required by:
familywall-android:app:unspecified
<a href="searchInBuildFiles">Search in build.gradle files</a>
Run Code Online (Sandbox Code Playgroud)
有人经历过类似的事吗?
我有 ActivityA 作为启动器活动。
从 ActivityA 我打开 -> ActivityB。我把应用程序放在后台。
当我从最近打开应用程序时,应用程序将通过 ActivityB 恢复。当我从主屏幕打开应用程序时,应用程序将通过 ActivityA 恢复,而无需调用 onCreate(),只需调用 onResume()。
当我从主屏幕打开应用程序时,为什么 ActivityB 从堆栈中清除,即使从未调用 ActivityA 的 onCreate() ,以及如何解决此问题?
清单文件如下所示:
活动A:
<activity-alias
android:name=".Launcher"
android:label="@string/app_name"
android:targetActivity="path.ActivityA">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
<activity
android:name=".path.ActivityA"
android:launchMode="singleTask"
android:screenOrientation="sensorPortrait"
android:theme="@style/BlackIntroTheme"
android:windowSoftInputMode="adjustPan">
<nav-graph android:value="@navigation/graph1" />
<nav-graph android:value="@navigation/graph2" />
<nav-graph android:value="@navigation/graph3" />
<nav-graph android:value="@navigation/graph4" />
</activity>
Run Code Online (Sandbox Code Playgroud)
活动B:
<activity
android:name=".path.ActivityB"
android:launchMode="singleTask"
android:screenOrientation="sensorPortrait"
android:windowSoftInputMode="adjustPan" />
Run Code Online (Sandbox Code Playgroud) <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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/bottomSheetLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_top_round_corner">
<androidx.cardview.widget.CardView
android:id="@+id/cardViewInnerProductContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
app:cardElevation="10dp"
app:cardCornerRadius="10dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/closeIv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="12dp"
android:src="@drawable/ic_close_dark"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/changeAddressTitleTv"
style="@style/FontLocalizedBold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="7dp"
android:paddingStart="12dp"
android:text="@string/changeaddress_popup_change_address"
android:textColor="@color/colorTextPrimary"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/closeIv" />
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/colorDividerLight"
app:layout_constraintTop_toBottomOf="@id/closeIv" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/locationRv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/divider"
tools:listitem="@layout/item_choose_address" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/addressesRv"
android:layout_width="match_parent"
android:layout_height="200dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingBottom="4dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/locationRv"
tools:listitem="@layout/item_choose_address" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
val addressesLayoutManager = …Run Code Online (Sandbox Code Playgroud) android scroll kotlin android-recyclerview android-constraintlayout