简体   繁体   中英

Question about DP in Android

假设我更喜欢使用“ dp”,而不是“ fill_parent”或“ wrap_content”,那么使用什么合适的数字来填充图片?

This depends of the screen and of its density. Check this article to learn more about that.

(This may lead you to reconsider using fill_parent / wrap_content by the way).

Why would you "prefer" this? Precise dp values for layout_width / layout_height are one tool alongside match_parent and wrap_content and building a nice UI will usually involve all three. Which one is appropriate for each dimension of any given View is situational and match_parent 's entire reason for existence is to match the size of a View's container, in your case the screen.

(* match_parent is the newer name for fill_parent .)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM