我对java和android还是个新手。目前我正在学校学习java。我刚开始在这个计算器上工作,只是为了在android开发中有所作为。我目前的问题是,当我将应用程序部署到模拟器(手机大小为480x800)时,它看起来像Pic 001,但当我将它部署到我的Kindle fire第一代(我相信是1024x600)时,它看起来像Pic 002。我怎么才能让它在每部手机上看起来都一样。


发布于 2012-11-25 07:31:40
为了让你的按钮填满整个屏幕的宽度,把这个放到你的标签Button中
android:layout_width="0dp" android:layout_weight="1"而不是:
android:layout_width="80dp"如果您希望按钮更高:
change
Button change android:layout_height="80dp" to android:layout_height="match_parent".
LinearLayout包含您的按钮change android:layout_height="wrap_content" to android:layout_height="0dp" android:layout_weight="1".
TextView change android:layout_height="wrap_content" to android:layout_height="0dp" android:layout_weight="X",其中X是为您提供正确比例的值。你会看到一个警告,告诉你嵌套的权重对性能不好,但这是我知道的唯一的方法。
通常,如果希望组件填充空白空间,请将宽度或高度设置为0dp,然后添加一个权重。权重将定义想要填充空间的元素的比例。
我希望它能对你有所帮助。
https://stackoverflow.com/questions/13546583
复制相似问题