今天给大家带来的给最底层的布局添加控件的原理分析。首先看下效果吧↓
(我是给第一个Ima'ge)看完之后估计有些人认为很简单。具体你的看法是怎么样的我就不过多的猜测了,开始分析一下这个效果吧!首先大家看到了上面会有一块会弹上去,弹到顶之后又会恢复成直的。这种效果怎么实现呢,咱先不说 先说一下调用这个需要几行代码看我截图
这也是这篇博客的重点之一(●ˇ∀ˇ●) 。
重点2,这个自定义控件不是加在这个带有ScrollView的这个布局文件中的,是添加在了最顶层的布局文件。好了,开始分析了!!!
R.layout.activity_main:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/rl" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#f2f2f2"> <ScrollView android:layout_width="match_parent" android:layout_height="wrap_content"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <ImageView android:id="@+id/show" android:layout_width="match_parent" android:layout_height="300dp" android:src="@mipmap/ic_launcher" /> <ImageView android:layout_width="match_parent" android:layout_height="300dp" android:src="@mipmap/ic_launcher" /> <ImageView android:layout_width="match_parent" android:layout_height="300dp" android:src="@mipmap/ic_l