位置: 编程技术 - 正文

Activity添加新View(activity怎么用)

编辑:rootadmin
protected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.write_annot); SPSlate slate = new SPSlate(this); //view slate.setPenSize(2, ); slate.setPenColor(Color.RED); addContentView(slate, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

推荐整理分享Activity添加新View(activity怎么用),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:activity view,activity动态添加节点,activity加载流程,android新建activity,activity view,activity view,activity添加fragment,activity添加fragment,内容如对您有帮助,希望把文章链接给更多的朋友!

}

第二种:通过RelativeLayout, 来控制后添加的View的大小:大小填充的是RelativeLayout的大小。

Activity添加新View(activity怎么用)

RelativeLayout mLayout;@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.write_annot); SPSlate slate = new SPSlate(this); slate.setPenSize(2, ); slate.setPenColor(Color.RED); mLayout = (RelativeLayout)findViewById(R.id.writeAnnotateView); mLayout.addView(slate, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));}

xml: 配置文件

<?xml version="1.0" encoding="utf-8" ?><RelativeLayout xmlns:android=" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:layout_width="match_parent" android:layout_height="dp" android:orientation="horizontal"android:background="@android:color/darker_gray"> <ImageButton android:id="@&#;id/confirmBtn" android:layout_width="dp" android:layout_height="dp" android:layout_weight="1" android:background="@drawable/button" android:layout_gravity="center_vertical" android:src="@drawable/c_brushescheckmark_disabled"/> <ImageButton android:id="@&#;id/reDoBtn" android:layout_width="dp" android:layout_height="dp" android:layout_weight="1" android:background="@drawable/button" android:layout_gravity="center_vertical" android:src="@drawable/c_redo_disabled"/> <ImageButton android:id="@&#;id/unDoBtn" android:layout_width="dp" android:layout_height="dp" android:layout_weight="1" android:background="@drawable/button" android:layout_gravity="center_vertical" android:src="@drawable/c_undo_disabled"/> <ImageButton android:id="@&#;id/fontBtn" android:layout_width="dp" android:layout_height="dp" android:layout_weight="1" android:background="@drawable/button" android:layout_gravity="center_vertical" android:src="@drawable/icon_font"/> <ImageButton android:id="@&#;id/colorBtn" android:layout_width="dp" android:layout_height="dp" android:layout_weight="1" android:background="@drawable/button" android:layout_gravity="center_vertical" android:src="@drawable/icon_color"/> </LinearLayout> <RelativeLayout android:id="@&#;id/writeAnnotateView" android:layout_marginTop="dp" android:layout_width="match_parent" android:layout_height="match_parent"> </RelativeLayout> </RelativeLayout>

使用ObjectAnimator或者ValueAnimator来为控件使用动画 如果我要给一个控件做向右移动的动画,可以使用TranstateAnimation来使其向右移动,但是动画执行完成之后控件还是要回到起始位置。如果我需要让一个

BaseAdapter数据刷新,自定义BaseAdapter 在网上的视频看到的一个很好用的自定义BaseAdapter,自己修改了一下后一直在用,分享给大家,这样的话绑定gridView或listView就方便多了,直接在adapter里

IndicatorTabBar——可滑动的带指示条的TabBar 这篇文字给大家分享一个可以滑动的TabBar,这里叫做IndicatorTabBar。先上效果图:诸如网易新闻、腾讯新闻、百度新闻等客户端,都使用了类的TabBar,这

本文链接地址:https://www.jiuchutong.com/biancheng/379718.html 转载请保留说明!

上一篇:Android学习第10天(android基础入门)

下一篇:使用ObjectAnimator或者ValueAnimator来为控件使用动画(使用权资产)

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络