场景:
业务需要,在app的启动页面做一个模版,可以将广告图片直接插入进去....... 适合启动页广告、相框
思路:
相框原理,插入图片(本地图片和网络图片),为了更好的适配,采用百分比布局,图片宽高、位置,均通过设置百分比来调整,图片可以各种倾斜角度。
效果:
部分代码:
1.Add the RahmenView to the layout.xml file where you want to display the list;
android:id="@+id/rahmen_view_ad"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
app:rhv_anim="true"
app:rhv_backgroud="@drawable/bg_rahmen_2"
app:rhv_duration="1000"
app:rhv_image_height="@dimen/rhv_sp_height"
app:rhv_image_rotation="-7"
app:rhv_image_width="@dimen/rhv_sp_width"
app:rhv_image_x="@dimen/rhv_sp_left"
app:rhv_image_y="@dimen/rhv_sp_top"/>
mRahmenView.setOnRahmenListener(mOnRahmenListener);
OnRahmenListener mOnRahmenListener = new OnRahmenListener() { @Override
@Override
public void onLongClick(View view) {
super.onLongClick(view);
}
public void onClick(View view) {
super.onClick(view);
}
};
mRahmenView.setRahmenImage();
mRahmenView.getRahmenImageHeight()
mRahmenView.setRahmenImageWidth();
mRahmenView.getRahmenImageY()
mRahmenView.setRahmenImageY();
mRahmenView.setRahmenImageRotation();
mRahmenView.setRahmenForeground();
mRahmenView.setRahmenBackgroud();
完整代码:github
https://github.com/KernHu/RahmenView