【问题标题】:Android GUI LayoutAndroid GUI 布局
【发布时间】:2013-02-14 18:43:53
【问题描述】:

我目前正在尝试研究如何在我的 Android 应用程序的 GUI 中对齐某些元素。 请看下面的图片链接,第一个布局是当前的,第二个是我的目标。 目前,我正在使用两个线性布局。我尝试对右侧按钮和 EditText 使用相对布局和表格布局,但 EditText 总是缩小,或者超出平板电脑的屏幕尺寸。

感谢您的帮助!

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

【问题讨论】:

    标签: android image user-interface button android-edittext


    【解决方案1】:

    试试这个:

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        【解决方案3】:

        刚刚整理了一个快速模板,由于我只使用记事本,您可能需要修复 + 添加自己的属性:

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2011-09-12
          • 2018-05-03
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多