我正在尝试使用CoordinatorLayout关注Google文档,但我在CoordinatorLayout中遇到了ScrollView的问题.基本上,当向下滚动时,工具栏通常会使用RecyclerView或Listview折叠.现在使用ScrollView它不会崩溃.
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<TextView
android:id="@+id/tv_View"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/filler"
style="@style/TextAppearance.AppCompat.Large"
/>
</ScrollView>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
/>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud) android toolbar android-scrollview android-toolbar coordinator-layout
我想使用切换来在两个不同的视图之间切换,但使用相同的视图RecyclerView.基本上,一旦你切换,我想要RecyclerView适配器调用,onCreateViewHolder()但这次它将使用不同的布局项目文件.
是否notifydatasetchanged()导致适配器重建?或者还有另一种方式吗?
android android-adapter notifydatasetchanged android-recyclerview
我在CardView中使用了一个LinearLayout来获得一种社交媒体登录按钮外观,它运行良好,但Android Studio标记Element LinearLayout is not allowed here.我想知道为什么会这样呢?我的xml是这样的:
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_below="@id/cv_fb"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardElevation="3dp"
>
<LinearLayout
android:id="@+id/ll_entitlement_extend_google"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/white"
android:clickable="true"
android:gravity="center"
android:paddingTop="10dp"
android:paddingBottom="10dp"
>
<ImageView
android:layout_weight="1"
android:layout_width="75dp"
android:layout_height="75dp"
android:src="@drawable/google_icon"/>
<TextView
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Connect with Google +"/>
<ImageView
android:layout_weight="1"
android:layout_width="25dp"
android:layout_height="25dp"
android:src="@drawable/ic_chevron_right_black"/>
</LinearLayout>
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud) android android-layout android-linearlayout android-cardview
我正在尝试创建一个bash脚本来激活virtualenv,pip安装requirements.txt并继续。这将是我的init.sh脚本,供以后使用。
#!/usr/bin/env bash
set -euo pipefail
. ${DIR}/scripts-venv/bin/activate
pip install -r requirements.txt
Run Code Online (Sandbox Code Playgroud)
$ {DIR}设置为包含virtualenv的目录。看来问题出在上述set -euo内容上,根据某些样式指南,这是推荐开始使用bash脚本的起点。更具体地说,它的u选项-交互会产生错误/scripts-venv/bin/activate: line 57: PS1: unbound variable。我可以删除它,但是只是想知道为什么会这样。谢谢