0
有没有办法在MapView上创建连锁效果?MapView上的波动动画效果
我的布局显示在帖子结尾。 我知道关于android:background="?attr/selectableItemBackground"
,它对不同类型的视图很好,但不适用于MapView。
我想要的是对header_container
和map_view
的不可分割的连锁反应。
为了达到这个目的,我试图把它们放在RelativeLayout中,并在它们上面创建与selectableItemBackground
的视图,但是我不喜欢这个解决方案,因为我只能通过指定重叠视图的确切高度来使它工作,我希望它以匹配标题和地图的高度。
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:map="http://schemas.android.com/tools"
android:id="@+id/cv_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="@dimen/card_corner_radius"
card_view:cardElevation="@dimen/card_elevation"
card_view:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/header_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:orientation="vertical"
android:paddingLeft="@dimen/card_horizontal_padding"
android:paddingRight="@dimen/card_horizontal_padding">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/card_text_small_margin"
android:layout_marginTop="@dimen/card_text_big_margin"
android:text="Name"
android:textSize="@dimen/card_title_text_size" />
<TextView
android:id="@+id/tv_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/card_text_small_margin"
android:text="Address"
android:textSize="@dimen/card_subtitle_text_size" />
</LinearLayout>
<com.google.android.gms.maps.MapView
android:id="@+id/map_view"
android:layout_width="match_parent"
android:layout_height="@dimen/card_media_height"
map:liteMode="true"
map:mapType="none" />
<LinearLayout
android:id="@+id/button_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="@dimen/card_action_padding"
android:paddingTop="@dimen/card_action_padding">
<android.support.v7.widget.AppCompatButton
android:id="@+id/b_drive"
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/card_action_padding"
android:layout_marginRight="@dimen/card_action_padding"
android:minHeight="0dp"
android:minWidth="0dp"
android:padding="@dimen/card_action_padding"
android:text="@string/card_action_drive"
android:textColor="@color/color_primary" />
<android.support.v7.widget.AppCompatButton
android:id="@+id/b_walk"
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="0dp"
android:minWidth="0dp"
android:padding="@dimen/card_action_padding"
android:text="@string/card_action_walk"
android:textColor="@color/color_primary" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
谢谢你的回答,我现在正在测试它,请问您能否显示您的'R.drawable.ripple'? – Florin
只是一个普通的XML可绘制:https://developer.android.com/reference/android/graphics/drawable/RippleDrawable.html你必须看到你想要的颜色,如果有选择与否。这是你的设计。 – Budius