Get screen size & use style sheet android

Source: Internet
Author: User

Screen Size:

 
Displaymetrics dm = new displaymetrics (); getwindowmanager (). getdefadisplay display (). getmetrics (DM); DM. widthpixels; DM. heightpixels;

Use a style sheet:

Create a style. xml file under Res/Values

<? XML version = "1.0" encoding = "UTF-8"?> <Resources> <style name = "David styletext1"> <item name = "Android: textsize"> 24sp </item> <item name = "Android: textcolor "> # ec9237 </item> </style> <style name =" David styletext2 "> <item name =" Android: textsize "> 18sp </item> <item name =" Android: textcolor "> # ff7f7c </item> <item name =" Android: background ">#333333 </item> </style> </resources>

Write in the layout file:

 
<TextviewStyle = "@ style/David styletext1"Android: Id = "@ + ID/TV1" Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" Android: text = "I'm Wang Xin. I do it !! Please true me! "/>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.