如何布局我的android应用程序?

如何布局我的android应用程序?,android,android-layout,Android,Android Layout,我正在为我女儿写一份数学申请书。它应包括上一行的任务解决,一些进度条,然后键盘在左边和功能板在右边。这是我的想法: 我从一个包含一组线性布局的线性布局开始。Android studio认为嵌套权重的性能很差。除了5行功能外,我没有4行键盘。这是我目前的进展: 然后我使用了一个表布局,但它没有行跨度。因此,我切换到相对布局,但未能均匀分布行。最后一次尝试是网格布局,但我还是不能均匀地分布行 有什么想法,如何实现我的目标 看起来我几乎用LinearLayout做了你想做的事情。看一看截

我正在为我女儿写一份数学申请书。它应包括上一行的任务解决,一些进度条,然后键盘在左边和功能板在右边。这是我的想法:

我从一个包含一组线性布局的线性布局开始。Android studio认为嵌套权重的性能很差。除了5行功能外,我没有4行键盘。这是我目前的进展:

然后我使用了一个表布局,但它没有行跨度。因此,我切换到相对布局,但未能均匀分布行。最后一次尝试是网格布局,但我还是不能均匀地分布行

有什么想法,如何实现我的目标




看起来我几乎用LinearLayout做了你想做的事情。看一看截图,兄弟

   <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".CalcActivity" >

    <LinearLayout
        android:id="@+id/keyboard"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/seekbar"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="25dp"
        android:orientation="horizontal"
        android:weightSum="2" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:orientation="vertical" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >

                <Button
                    android:id="@+id/button6"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_margin="6dp"
                    android:text="9" />

                <Button
                    android:id="@+id/button7"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_margin="6dp"
                    android:text="8" />

                <Button
                    android:id="@+id/button8"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_margin="6dp"
                    android:text="7" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >

                <Button
                    android:id="@+id/button9"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_margin="6dp"
                    android:text="6" />

                <Button
                    android:id="@+id/button10"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_margin="6dp"
                    android:text="5" />

                <Button
                    android:id="@+id/button11"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_margin="6dp"
                    android:text="4" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >

                <Button
                    android:id="@+id/button12"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_margin="6dp"
                    android:text="3" />

                <Button
                    android:id="@+id/button13"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_margin="6dp"
                    android:text="2" />

                <Button
                    android:id="@+id/button14"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_margin="6dp"
                    android:text="1" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >

                <Button
                    android:id="@+id/button15"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_margin="6dp"
                    android:text="," />

                <Button
                    android:id="@+id/button16"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_margin="6dp"
                    android:text="0" />

                <Button
                    android:id="@+id/button17"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_margin="6dp"
                    android:text="=" />
            </LinearLayout>
        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:orientation="vertical" >

            <Button
                android:id="@+id/button1"
                style="?android:attr/buttonStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="←" />

            <Button
                android:id="@+id/button2"
                style="?android:attr/buttonStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="+" />

            <Button
                android:id="@+id/button3"
                style="?android:attr/buttonStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="-" />

            <Button
                android:id="@+id/button4"
                style="?android:attr/buttonStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="/" />

            <Button
                android:id="@+id/button5"
                style="?android:attr/buttonStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="*" />
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/assignment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="25dp"
        android:orientation="horizontal"
        android:weightSum="5" >

        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:text="50"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
             android:gravity="center"
            android:text="+"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
             android:gravity="center"
            android:text="51"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/textView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
             android:gravity="center"
            android:text="="
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/textView5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
             android:gravity="center"
            android:text="101"
            android:textAppearance="?android:attr/textAppearanceLarge" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/seekbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/assignment"
        android:layout_below="@+id/assignment"
        android:layout_marginTop="32dp"
        android:orientation="horizontal" >

        <SeekBar
            android:id="@+id/seekBar"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_weight="3" />

        <ImageView
            android:id="@+id/progressImage"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:src="@drawable/ic_launcher" />
    </LinearLayout>

</RelativeLayout>

由于我没有这些风格,我不得不把它删除

编辑截图:

chiru的组合真不错。我只是想让它填满屏幕。怎么做?玩重量游戏?用不同的重量、边距和填充物进行测试bro甚至relativelayout setparentbottom=true可能会帮助你提高。我自己也曾几次如此接近,但我未能扩展布局以填满整个屏幕。一旦我成功了,我会接受你的答案。关于android studio提示“嵌套权重对性能有害”,我可以忽略它吗?我仍然在使用eclipse,对此不确定。你可以谷歌一下,兄弟。现在看看我编辑过的答案。