我有麻烦了。在我的应用程序中,我有一些(3-4)按钮,它们希望自动缩放到全屏幕大小。(不只是一个按钮,而是所有的一起)。目前我正在使用LinearLayout作为我的应用程序。能用它来做这个吗?对不起我的英语不好。
问候尼尔斯
游戏“不要点击白色”的屏幕就像我喜欢的那样:

发布于 2014-06-12 07:53:52
你可以使用重量的概念。你的按钮在所有屏幕上都是一样的。
首先,将屏幕分成两个水平部分,宽度、重量各50,高度匹配。然后在每个重量为33.33的部件上添加3个按钮如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_weight="50"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="33.33"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="33.33"
android:text="Button" />
<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="33.33"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="50"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="33.33"
android:text="Button" />
<Button
android:id="@+id/button5"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="33.33"
android:text="Button" />
<Button
android:id="@+id/button6"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="33.33"
android:text="Button" />
</LinearLayout>
</LinearLayout>发布于 2014-06-12 07:54:36
丑陋的解决方案将是使用3加权LinearLayouts (相同的权重)垂直,而使用加权水平LinearLayout实现相同的效果水平。
或者您可以使用GridView以更优雅的方式实现类似的效果:http://developer.android.com/guide/topics/ui/layout/gridview.html
发布于 2014-06-12 07:56:13
将按钮的宽度设置为match_parent。然后,它将规模,以适应父母。
https://stackoverflow.com/questions/24179088
复制相似问题