Dec
10
现在,吵吵闹闹的要生产Android手机的厂商越来越多,从开发者的角度来说,不能不说这是一件好事,毕竟写出来的程序可以顺利的跑在更多的设备上,但是参差不及的硬件选择也给我们带来了很大的麻烦,最直接的就是不同的手机屏幕的尺寸可能不一样,又不能为每种尺寸都设计一套布局,所以就有可能需要在程序运行时来通过屏幕的大小来动态的调整一些布局相关的参数。那如何获得屏幕的大小呢?
在android.app.Activity中提供这样的方法:
DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); int screenWidth = dm.widthPixels; int screenHeight = dm.heightPixels;
其中,screenWidth就是屏幕的宽度,screenHeight就是屏幕的高度。
如果将手机从肖像模式(竖着拿)变成风景模式(横着拿),这两个值也会随之改变,所以,也许我们不用这种方法,也可以推算出手机的手持方式,从而来改变一些布局参数。
Tags: DisplayMetrics, 屏幕尺寸
May 18th, 2010 at 8:04
Hello! kcfafkd interesting kcfafkd site!
May 18th, 2010 at 8:05
Very nice site! cheap viagra
May 18th, 2010 at 8:05
Very nice site! [url=http://aixopey.com/qqatat/2.html]cheap cialis[/url]
May 18th, 2010 at 8:05
Very nice site! cheap cialis http://aixopey.com/qqatat/4.html
May 18th, 2010 at 8:05
Very nice site!
May 20th, 2010 at 7:13
Hello!
buy cialis ,
June 24th, 2010 at 3:15
Hello! feceged interesting feceged site!
June 24th, 2010 at 3:15
Very nice site! cheap viagra
June 24th, 2010 at 3:15
Very nice site! [url=http://opeyixa.com/rvqatx/2.html]cheap cialis[/url]
June 24th, 2010 at 3:16
Very nice site! cheap cialis http://opeyixa.com/rvqatx/4.html
June 24th, 2010 at 3:16
Very nice site!
June 28th, 2010 at 8:52
http://www.roiding.com is very interesting. I enjoyed your blog a lot. Thank you.
June 30th, 2010 at 1:02
Hello!
cialis ,
July 1st, 2010 at 7:16
Hello!
buy viagra ,
July 2nd, 2010 at 5:09
Hello!
viagra online ,
July 5th, 2010 at 4:17
Hello!
viagra ,
July 5th, 2010 at 4:17
Hello!
cialis ,
July 6th, 2010 at 8:00
Hello!
viagra online ,
July 7th, 2010 at 2:16
Hello!
viagra ,
July 7th, 2010 at 3:11
Tucked away in our timberland for you subconscious is an idyllic vision. We see ourselves on a long trip that timberland 6 inch spans the continent. We are traveling by train. Out timberland hiking boots windows, we drink in the passing scene of cars on nearby highways, of children timberland shoe company waving at a crossing, of cattle grazing on a distant timberland boots hillside, of smoke pouring from a power plant, of row upon row of corn and wheat, of flatlands and timberland wheat shoes valleys, of mountains and rolling classic 3 eye timberland boat hillsides, of city skylines and village halls.But uppermost in our black timberland boots minds is the final destination. On a certain cheap timberland boots day at a certain hour, we will pull into the station. Bands will be playing and flags discount timberland boots waving. Once we get there, so many wonderful timberland winter boots dreams will come true and the pieces of our lives will fit together like a completed jigsaw puzzle. How restlessly we pace the aisles, womens timberland boot the minutes for loitering –waiting, waiting, waiting for the station.But uppermost in our timberland shoes store minds is the final destination. On a certain day at a certain hour, we will pull into the station. Bands will be playing and timberland eye boat flags waving. http://www.timberland6inch.com/
July 8th, 2010 at 4:27
Hello!
viagra ,
July 9th, 2010 at 3:49
Hello!
viagra online ,
July 11th, 2010 at 1:10
http://www.roiding.com is great! No faing payday loans offer small amount of money without taking any assets from the borrowers The service is also free from lengthy formalities and paperwork
July 12th, 2010 at 4:27
Hello!
cheap cialis ,
July 14th, 2010 at 6:45
Hello!
cheap viagra ,
July 14th, 2010 at 6:46
Hello!
buy viagra ,
July 15th, 2010 at 7:47
Hello!
viagra ,
July 15th, 2010 at 7:48
Hello!
cialis ,
July 17th, 2010 at 5:25
Hello!
cialis ,
July 19th, 2010 at 12:53
Hello!
cheap viagra ,
July 19th, 2010 at 12:53
Hello!
cialis ,
July 20th, 2010 at 1:58
Hello!
cialis ,
July 22nd, 2010 at 2:26
Hello!
viagra ,
July 23rd, 2010 at 11:41
so much of it rings true..
July 23rd, 2010 at 2:30
Hello!
cheap viagra ,
July 23rd, 2010 at 2:31
Hello!
cialis ,
July 23rd, 2010 at 9:55
I agree wholeheartedly.
July 26th, 2010 at 5:44
Hello!
cheap cialis ,
July 26th, 2010 at 5:44
Hello!
viagra ,
July 27th, 2010 at 8:12
Hello!
cialis ,
July 27th, 2010 at 8:12
Hello!
viagra ,
July 28th, 2010 at 8:11
Hello!
viagra ,
July 29th, 2010 at 7:30
Hello!
buy cialis ,
July 29th, 2010 at 7:31
Hello!
viagra online ,
July 30th, 2010 at 6:26
Hello!
cheap viagra ,
July 30th, 2010 at 6:26
Hello!
viagra ,