我试图获得与谷歌播放中看到的相似的效果.
我有以下布局,以显示一个透明的工具栏,后面有一个图像.当用户滚动时,在图像视图滚动离开屏幕时会出现视差效果.当用户向上滚动时,工具栏会返回,只有当用户到达列表的lop时,imageview才会返回.
一切都很好.
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main"
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.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="@color/background_material_dark">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsingToolbarLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
app:statusBarScrim="#09b"
app:contentScrim="#09f">
<ImageView
android:id="@+id/img"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/location_banner"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7"
/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
app:layout_collapseMode="pin"
android:fitsSystemWindows="true"
app:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
当我将windowTranslucentStatus设置为true时.视图中的内容向上移动到状态栏下方,但CollapsingToolbarLayout的内容向上移动状态栏高度的两倍(CollapsingToolbarLayout保持正确的高度).
这意味着图像顶部的某些部分被切断,操作栏现在显示在状态栏下方而不是在其下方.作为一个副作用,现在在CollapsingToolbarLayout底部的填充与状态栏的高度相同
这是没有windowTranslucentStatus的样子.这里的一切都很好

windowTranslucentStatus设置为true

用户从列表中的较低位置向上滚动(不在顶部)

android statusbar android-actionbar android-coordinatorlayout android-collapsingtoolbarlayout
我需要根据使用的产品风味创建不同的应用程序名称。
虽然通过简单地设置字符串资源很容易,但我不能再这样做了,因为当应用程序上传到 hockeyapp 时,应用程序名称设置为“@string/app_name”而不是 app_name 的值。
通过将清单中的标签设置为 '${applicationName}' 并将值设置为
manifestPlaceholders = [ applicationName : appName ];
Run Code Online (Sandbox Code Playgroud)
在产品风味块中,以便在编译时设置该值。
当我尝试将构建类型附加到应用程序名称时,问题就出现了。我似乎无法找到一种方法来了解当前在产品风味中使用的构建类型。
这是一个精简版本的构建以提高可读性
android {
buildVersionName "1.0.0
buildTypes {
release {
... nothing special
}
uat {
signingConfig signingConfigs.debug
buildType = "uat"
applicationIdSuffix = "." + buildType
}
debug {
signingConfig signingConfigs.debug
buildType = "uat"
applicationIdSuffix = "." + buildType
}
}
productFlavors{
flavor1{
def appName = "app name " + buildType;
manifestPlaceholders = [ applicationName : appName ];
applicationId [id]
def clientIteration = …Run Code Online (Sandbox Code Playgroud) 我按照本指南https://developers.google.com/analytics/devguides/collection/android/v4/进行操作,并讨论如何在Application类中创建一个获取默认跟踪器的方法.
在getDefaultTracker()中,它引用了R.xml.global_tracker.它没有告诉你的是,当json文件放入应用程序模块的根目录时,会自动生成此文件.
这适用于新项目.
问题
我现有的项目(目前正在使用analytics V2)具有产品风格,因此将json放入应用程序模块的根目录是没有意义的,因为包名称和UA id对于每种风格都是不同的.
我试图让它在一个新项目(为简单起见)中使用产品风味,但它不起作用.
可能解决方案
由于我刚从V2升级,因此自动生成的文件与我现有的analytics.xml相同.两者似乎都包含相同的属性'ga_trackingId'.
我可以将相同的xml传入analytics.newTracker()并且根本不添加json.如果是这种情况,我也可以忽略构建脚本中的以下两部分
classpath 'com.google.gms:google-services:1.4.0-beta3'
Run Code Online (Sandbox Code Playgroud)
和
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)
奖金问题
我目前在analytics.xml中设置了屏幕名称
<string name="[full screen path]">[screen name]</string>
Run Code Online (Sandbox Code Playgroud)
在V4中跟踪屏幕它说
mTracker.setScreenName("Image~" + name);
Run Code Online (Sandbox Code Playgroud)
我现在必须在代码中明确设置屏幕名称吗?
我有一个Android应用程序需要为不同的环境(例如,UAT,登台,制作等)构建.每个环境都需要不同的属性(例如,URL,包等).
我想将所有不同的参数放入单个属性文件中,并为每个参数添加前缀与其匹配的环境.
例如,属性文件将包含dev.home-url = http://home_dev.com开发环境和prod.home-url = http://home.com生产环境.
我使用下面的方法创建一个属性,指向属性文件,前缀为params:
<property file="parameters.properties" prefix="params" />
Run Code Online (Sandbox Code Playgroud)
并使用属性,我使用:
${params.home-url}
Run Code Online (Sandbox Code Playgroud)
当我需要将环境的前缀添加到参数时,问题出现了.它最终看起来像这样,显然无法做到:
${params.${env-prefix}.home-url}
Run Code Online (Sandbox Code Playgroud) android ×4
android-collapsingtoolbarlayout ×1
ant ×1
build ×1
build.gradle ×1
gradle ×1
json ×1
statusbar ×1