当在片段内滚动recyclerView时,我使用支持设计库来显示/隐藏工具栏,如https://github.com/codepath/android_guides/wiki/Handling-Scrolls-with-CoordinatorLayout
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:layout_scrollFlags="scroll|enterAlways"/>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/flContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
它工作,现在我想以编程方式启用/禁用工具栏滚动,因为我使用片段,我需要为某些片段停止此功能.
我正在尝试使用./gradlew assembleDebug在Linux无头服务器上使用gradle创建调试apk文件,但是我得到以下错误
java.io.IOException: Cannot run program "/usr/android/android-sdk-linux/build-tools/23.0.1/aapt": java.io.IOException: error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:494)
at com.android.builder.png.AaptProcess$Builder.start(AaptProcess.java:138)
at com.android.builder.png.QueuedCruncher$1.creation(QueuedCruncher.java:96)
at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:188)
at java.lang.Thread.run(Thread.java:701)
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.<init>(UNIXProcess.java:164)
at java.lang.ProcessImpl.start(ProcessImpl.java:81)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:476)
... 4 more
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Crunching Cruncher abc_btn_radio_to_on_mtrl_000.png failed, see logs
Run Code Online (Sandbox Code Playgroud) 我有一个矢量drawable(category_bg),我用它作为FrameLayout的背景
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="200dp"
android:height="100dp"
android:viewportWidth="600"
android:viewportHeight="450">
<path
android:fillColor="#FFFFFF"
android:fillType="evenOdd"
android:pathData="M24.8,21.4c0,0,73.8-8.1,161.3-8.1c77.7,0,153.9,2,231.9,2c88.5,0,156.3,6,156.3,6c5.6,0,10.1,4.5,10.1,10.1
c0,0,2,41.2,2,134.1c0,68.5,4,77.9,4,139.1c0,65-6,114.9-6,114.9c0,5.6-4.5,10.1-10.1,10.1c0,0-32.1,7.1-80.6,7.1
c-47.5,0-99.6-7.1-164.7-7.1c-77.6,0-160.9,6-219.4,6c-52.8,0-84.7-6-84.7-6c-5.6,0-10.1-4.5-10.1-10.1c0,0-4-46.6-4-111.9
c0-85.8-1-102.9-1-183.5c0-55,5-92.7,5-92.7C14.7,25.9,19.2,21.4,24.8,21.4z" />
</vector>
Run Code Online (Sandbox Code Playgroud)
我想在矢量drawable中添加阴影
我的xml文件
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/category_bg"
android:padding="3dp">
<com.shaker.materialComponents.view.MaskableFrameLayout
android:id="@+id/category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:mask="@drawable/pic_mask"
app:porterduffxfermode="DST_IN">
<com.shaker.materialComponents.view.AspectRatioImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/meal"
app:aspectRatio="0.75"
app:aspectRatioEnabled="true"
app:dominantMeasurement="width"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@drawable/category_gradient_bg"
android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="20dp">
<com.shaker.materialComponents.view.MaterialTextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:lines="1"
android:text="Salads"
android:textColor="#fff"
android:textSize="18dp"
android:textStyle="bold"
app:customFont="GothamRounded-Bold.ttf"/>
<ImageView
android:id="@+id/expand_btn"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/expand_button"/>
</LinearLayout>
</com.shaker.materialComponents.view.MaskableFrameLayout>
Run Code Online (Sandbox Code Playgroud)
目前的结果
添加阴影后应该是这样的