2013-02-28 127 views
0

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

感谢您的帮助!

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

回答

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

你为什么不使用RelativeLayout并在您EditText使用android:layout_alignBottom="myImage"

0

就汇聚了快速的模板,你可以需要修复+添加自己的属性,因为我只使用记事本:

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