android Xml生成一条细线,以及获取屏幕宽度和高度


<View
 android:layout_width="match_parent" 
android:layout_height
="2dip" android:background="#FF909090"
android:layout_marginLeft
="40dip" android:layout_marginRight="40dip"
android:layout_marginTop="10dip" />

转载http://www.cnblogs.com/henryxu/archive/2013/04/10/3012081.html

//android获取屏幕的高度和宽度用到WindowManager这个类,两种方法: 
 //第一种
WindowManager wm = (WindowManager) getContext()
                    .getSystemService(Context.WINDOW_SERVICE);
 
     int width = wm.getDefaultDisplay().getWidth();
     int height = wm.getDefaultDisplay().getHeight();
 //第二种
WindowManager wm = this.getWindowManager();
 
     int width = wm.getDefaultDisplay().getWidth();
     int height = wm.getDefaultDisplay().getHeight();

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM