我有一个协调器布局,包含一个折叠工具栏,一个嵌套的滚动视图和一个浮动按钮.我的浮动按钮位于折叠工具栏的右下端.当折叠工具栏完全折叠时,我希望按钮消失.并在其他情况下可见.
我的xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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="match_parent"
android:fitsSystemWindows="true"
tools:context="fr.djey.secretapp.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"
android:id="@+id/appBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapse_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
<ImageView
android:id="@+id/collapsing_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"
android:scaleType="centerCrop"
android:src="@drawable/welcome"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:layout_gravity="fill_vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/content_frame">
</FrameLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-60dp"
android:layout_marginRight="16dp"
android:src="@android:drawable/ic_dialog_email"
app:layout_anchor="@id/collapse_toolbar"
app:layout_anchorGravity="bottom|right|end" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
有可能吗?怎么样?
android android-design-library android-collapsingtoolbarlayout
我的活动中有一个折叠工具栏,带有导航视图.我已按照教程设置折叠工具栏,但我不能让工具栏透明,就像我在网站上看到的那样.
我希望它在展开时是透明的(参见下图),在折叠时不透明:
这是我的main.xml:
<android.support.design.widget.CoordinatorLayout 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="match_parent"
android:fitsSystemWindows="true"
tools:context="fr.djey.secretapp.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapse_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/image"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"
android:scaleType="centerCrop"/>
<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/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/lorem_ipsum"
android:textColor="@android:color/black"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</android.support.v4.widget.NestedScrollView>
<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>
Run Code Online (Sandbox Code Playgroud) 我有这个错误:
Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzrf.class
Run Code Online (Sandbox Code Playgroud)
我想将google play服务添加到我的项目中,所以我把这行放在build.gradle文件中:
compile 'com.google.android.gms:play-services:7.8.0'
Run Code Online (Sandbox Code Playgroud)
所以我必须启用multidex并且我遵循android doc,在build.gradle中添加它:
compile 'com.android.support:multidex:1.0.1'
Run Code Online (Sandbox Code Playgroud)
和
multiDexEnabled true
Run Code Online (Sandbox Code Playgroud)
我在android清单中添加了这个:
<application
...
android:name="android.support.multidex.MultiDexApplication">
Run Code Online (Sandbox Code Playgroud)
但我有上面写的错误.我发现了很多关于这个问题的问题(app:packageAllDebugClassesForMultiDex)但没有找到(重复条目:com/google/android/gms/internal/zzrf.class).
我尝试了一些解决方案,比如删除一些谷歌库,但我不知道是什么引用内部/ zzrf.class.
这是我的gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "fr.djey.testgoogleplus"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.android.support:multidex:1.0.1'
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的应用中设置profilepictureview:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="fr.djey.testf.MainFragment"
xmlns:facebook="http://schemas.android.com/apk/res-auto">
<com.facebook.login.widget.ProfilePictureView
android:id="@+id/facebook_avatar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/login_button"
android:layout_centerHorizontal="true"
/>
<com.facebook.login.widget.LoginButton
android:id="@+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp"
android:layout_centerInParent="true"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我想为图片设置小尺寸。我在互联网上发现必须将facebook:preset_size = small放进去,但是似乎已经不存在了。
您能告诉我是否有另一种方法可以在xml中(而不是在Java中)执行此操作吗?
我尝试选择具有相同类的所有元素,并对它们执行css().
它在元素有一个类时有效,但是当它们有两个类时,它们不会被选中.
我的元素:
var ville;
$("#enigme1_answers td").hover(
function() {
ville = $(this).html().toLowerCase();
$( "[class=" + ville + "]" ).css("background-color", "red");
}, function() {
$( "[class=" + ville + "]" ).css("background-color", "#2a3843");
}
);Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<tr>
<td class="oslo"> O </td>
<td class="oslo lecaire"> L </td>
<td class="oslo viennes"> S </td>
<td class="oslo gaborone"> O </td>
<td class=erevan"> V </td>
<td class="berlin"> N </td>
<td class="rome"> E </td>
<td class="athenes"> S </td>
<td class="athenes"> E </td>
<td class="athenes"> N </td>
<td …Run Code Online (Sandbox Code Playgroud)