SDK编写模式采用ABtesting方案
1.每个库的使用都是采用重定义样式,更改XML配置即可,若你还是需要变动代码,那就说明你的使用方式有误。
如有3个功能,【拍照上传原图,拍照上传头像,拍照上传4:3截图,拍照上传不规则截图】,只需要配置不同的样式即可。
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- 重写样式,不开启裁剪 -->
<style name="MyDivPhotoGraph" parent="@style/DivPhotoGraph">
<item name="graph_iscrop">false</item>
</style>
<!-- 重写样式,裁剪比率为1:1正方形 -->
<style name="MyDivPhotoGraph" parent="@style/DivPhotoGraph">
<item name="graph_clip_width">1</item>
<item name="graph_clip_height">1</item>
</style>
<!-- 重写样式,裁剪比率为4:3长方形 -->
<style name="MyDivPhotoGraph" parent="@style/DivPhotoGraph">
<item name="graph_clip_width">4</item>
<item name="graph_clip_height">3</item>
</style>
<!-- 重写样式,不按比例裁剪 -->
<style name="MyDivPhotoGraph" parent="@style/DivPhotoGraph">
<item name="graph_auto_scale">false</item>
</style>
</resources>
2.肌肉记忆模式。建议先基于SDK库,建立多个test_xxx_styles.xml配置。在具体项目使用中,直接复制过去。
3.View库的使用,只要在XML更改下引用路径,并且在目标项目代码引用中,并不需要引用到依赖库的路径。当然你要引用引用依赖库的路径也是可以的,只是这种方式不推荐。引用在实际的项目中,产品会不断让你更改界面布局之类。这样做的目的是为了,只需要一句话更改布局,代码不动,快速满足产品更改需求。
/**只需要再布局中更改引用路径*/
<General.View.BlurImageView
android:id="@+id/img0"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="15dip"
android:src="@drawable/heng" />
/**在代码中还是维持android的imageview引用*/
import android.widget.ImageView;
4.若想更改依赖库的界面,请把依赖库layout下的xml布局文件,复制到目标项目的layout。在保持ID不变的情况下,可任意排版。
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFffffff"
android:orientation="vertical" >
<SurfaceView
android:id="@id/surface"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<!--更改浏览器的布局,保持id名称不变即可-->
<General.View.WebView
android:id="@id/webview"
style="@style/MyDivWebView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</FrameLayout>
5.若想更改某个依赖库的一个图片,只需要把依赖库需要改变的图片,复制到目标项目,在保持文件名称一致的情况下更改。如微信分享图标umeng_div_weixin.png
更改为