Android的:如何大小的按钮? [英] Android: How to size buttons?

查看:90
本文介绍了Android的:如何大小的按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用我的应用程序几个按钮,但两者layout_width /身高WRAP_CONTENT和FILL_PARENT看上去怪怪的。前者小,后者太大 - 这两个看起来奇怪,和以前是不容易用手指打

I'm using several buttons in my app, but both layout_width/height "wrap_content" and "fill_parent" looks weird. The former being to small and the latter too large - both looks weird, and the former is not easy to hit with your finger.

我应该如何大小的按钮?它是典型的定义在浸它们的大小?或者我应该用FILL_PARENT用填充?按钮看起来奇怪我的应用程序,不是那么别人。

How should I size buttons? Is it typical to define their sizes in dip? Or should I use "fill_parent" with a padding? Buttons looks weird in my app, not so in others.

推荐答案

这是很难抽象地回答。以下是一些技巧来考虑:

That is difficult to answer in the abstract. Here are some techniques to consider:


  • 使用的android:填充=4dip(或其他值),以使 WRAP_CONTENT 按钮大一点

  • Use android:padding="4dip" (or some other value) to make a wrap_content Button a bit bigger

使用的android:TEXTSIZE 按钮来使内容更大(使用缩放一些大小像素或 SP

Use android:textSize on the Button to make the content bigger (use some size in scaled pixels, or sp)

如果您想要的按钮,以填补空间,但它们之间划分它,使用的LinearLayout ,给每个按钮的高度(或宽度,取决于是否列或的行)0像素,然后用的android:layout_weight 来的百分数分配它们之间的空间。 这里是概述这种技术的示例项目。

If you want the buttons to fill the space but divide it among themselves, use a LinearLayout, give each button a height (or width, depending if column or row) of 0px, then use android:layout_weight to allocate space between them on a percentage basis. Here is a sample project outlining this technique.

这篇关于Android的:如何大小的按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆