我在约束布局中有一个recyclerView,我无法使其滚动,列表只是在屏幕下方继续,没有滚动可能性.如果我将布局转换为相对布局,滚动工作正常.
怎么才能让它滚动?
以下XML显示了我的布局,Recycler视图位于底部.布局在屏幕顶部有一个图像和描述.此屏幕设置占用屏幕的30%.然后是一个分隔符和一个应该占据屏幕其余部分并且无法滚动的回收器视图
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gradient_top">
<android.support.v7.widget.AppCompatImageView
android:id="@+id/imageViewLock"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="16dp"
app:layout_constraintBottom_toTopOf="@+id/textViewPermissionsTitle"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_phone_lock"/>
<TextView
android:id="@+id/textViewPermissionsTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:gravity="center"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:text="@string/allow_permissions"
android:textColor="@color/white"
android:textSize="@dimen/description_text_size"
app:layout_constraintBottom_toTopOf="@+id/guideline1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
<android.support.constraint.Guideline
android:id="@+id/guideline1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.3"/>
<View
android:id="@+id/viewSeparator"
android:layout_width="match_parent"
android:layout_height="0.7dp"
android:layout_marginTop="10dp"
android:background="@color/bright_blue"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline1"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewPermissions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbarSize="1dp"
android:scrollbarThumbVertical="@color/white"
android:scrollbars="vertical"
app:layout_constraintTop_toBottomOf="@+id/viewSeparator" />
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud) android android-scrollview android-recyclerview android-constraintlayout
我正在将一个应用程序迁移到 MVVM 和干净的架构,但我遗漏了这个难题的一部分。
问题域:
列出设备上的所有应用程序并将其显示在 Fragment / Activity 中
设备应用程序由其包名称表示:
data class DeviceApp(val packageName: String)
设备应用程序的列出方式如下:
private fun listAllApplications(context: Context): List<DeviceApp> {
val ans = mutableListOf<DeviceApp>()
val packageManager: PackageManager = context.applicationContext.packageManager
val packages = packageManager.getInstalledApplications(PackageManager.GET_META_DATA)
for (applicationInfo in packages) {
val packageName = applicationInfo.packageName
ans.add(DeviceApp(packageName))
}
return ans
}
Run Code Online (Sandbox Code Playgroud)
据我了解,调用listAllApplications()应该在“域层”内的用例中完成,该用例由ViewModel.
但是listAllApplications收到一个Context, 并且域层应该只是纯代码。
在干净的架构/MVVM 中,我应该放在哪一层listAllApplications(context)?
更一般地说,ViewModel 应如何与需要Context(位置等)的 Android 框架 API 进行交互?
我正在关注TensorFlow教程。我已经在python 3.6中安装了Tensorflow r1.9
我有休闲的进口:
from tensorflow.examples.tutorials.mnist import input_data
Run Code Online (Sandbox Code Playgroud)
我以休闲的方式使用它:
mnist = input_data.read_data_sets("mnist_data/", one_hot=True)
Run Code Online (Sandbox Code Playgroud)
我得到了休闲的警告/错误:
read_data_sets (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating: Please use alternatives such as official/mnist/dataset.py from tensorflow/models.
python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:260: maybe_download (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.
Instructions for updating:
Please write your own downloading logic.
Run Code Online (Sandbox Code Playgroud)
在r1.9中使用mnist的正确方法是什么?