Paste_Image.png
要實現這種效果,
子view在父的之上,
關鍵代碼如下
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:background="@color/gray"
android:clipChildren="false"
android:clipToPadding="false">
<LinearLayout
android:id="@+id/ShopDetailBuyLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/white"
android:clipChildren="false"
android:clipToPadding="false"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/View_margin_10"
android:layout_marginRight="@dimen/View_margin_10"
android:clipChildren="false"
android:clipToPadding="false"
android:paddingTop="@dimen/View_margin_10">
<ImageView
android:id="@+id/ShopDetailFrameIv"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:background="@drawable/gray_stroke_bg1"
android:padding="@dimen/View_margin_5"
android:scaleType="fitCenter"
android:src="@drawable/img_artbean"
android:translationY="@dimen/ShopDetailIvTransition" />
主要用到的屬性
1 、clipToPadding就是說控件的繪制區域是否在padding里面的,true的情況下如果你設置了padding那么繪制的區域就往里縮,
2、clipChildren是指子控件是否超過padding區域,
這兩個屬性默認是true的,所以在設置了padding情況下,默認滾動是在padding內部的,要達到上面的效果主要把這兩個屬性設置了false那么這樣子控件就能畫到padding的區域了。
3、位置上移
android:translationY
<dimen name="ShopDetailIvTransition">-20sp</dimen>
參考:
http://www.cnblogs.com/xitang/p/3606578.html
http://www.tuicool.com/articles/32YRJrq