简体   繁体   English

Android GUI布局

[英]Android GUI Layout

I am currently trying to work out how to align certain elements within my Android app's GUI. 我目前正在尝试找出如何在Android应用程序的GUI中对齐某些元素。 Please see the image link below, the first layout is the current one, and the second is what I am aiming for. 请查看下面的图像链接,第一个布局是当前布局,第二个是我的目标。 Currently, I am using two linear Layouts. 目前,我正在使用两个线性布局。 I have tried to use relative and table layouts for the right hand buttons and EditText, but always the EditText is shrunk, or overflows the tablet's screen size. 我曾尝试对右按钮和EditText使用相对和表格布局,但是EditText总是缩小,或溢出数位板的屏幕大小。

Thanks for your help! 谢谢你的帮助!

Image Link: ( http://postimage.org/image/pptkdkomx/ ) 图片链接:( http://postimage.org/image/pptkdkomx/

Try this: 尝试这个:

<?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" >

<ImageView
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="0.5" />

<LinearLayout
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="0.5"
    android:orientation="vertical" >

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

        <Button
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.5" android:text="Button1"/>

        <Button
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"  android:text="Button2"/>
    </LinearLayout>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>

</LinearLayout>

为什么不使用RelativeLayout而在EditText使用android:layout_alignBottom="myImage"

Just brought together a quick template, you may need to fix + add your own attributes since I used only notepad: 只是集合了一个快速模板,您可能需要修复并添加自己的属性,因为我仅使用了记事本:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="50"/>

    <LinearLayout 
        android:orientation="vertical"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="50">

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

            <Button android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="50"/>

            <Button android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="50"/>

        </LinearLayout>

        <EditText
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

    </LinearLayout>

</LinearLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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