Как добавить еще одну кнопку или текстовое представление рядом с другой кнопкой? - PullRequest
0 голосов
/ 27 февраля 2011

Как я могу добавить еще одну кнопку или текстовое представление рядом с другой кнопкой?Я новичок в программировании на Android и XML. Вот мой код xml:

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

    android:background="@drawable/background_start"
     >

 <Button 

         android:id="@+id/prvo"
         android:text="Прво копче" 
         android:textStyle="bold"
         android:layout_marginTop="25px"
         android:layout_margin="15px"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:visibility="visible"

         android:onClick="hello"
         />
 <EditText android:maxLines="1" 
 android:scrollbars="vertical" 
 android:text="Пиши нешто овде" 
 android:layout_width="match_parent" 

 android:id="@+id/editText1" 
 android:layout_height="wrap_content">
 </EditText>
</LinearLayout>

Должен ли я изменить шаблон макета?Switchit к относительному или табличному расположению вместо линейного?

1 Ответ

3 голосов
/ 27 февраля 2011
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
<Button
    android:text="Blah" 
    android:id="@+id/addemail" 
    android:layout_height="wrap_content"
    android:layout_width="wrap_content">
</Button>
<Button
    android:text="Blergh" 
    android:id="@+id/sendmail" 
    android:layout_height="wrap_content"
    android:layout_width="wrap_content" >
 </Button>
</LinearLayout>
</LinearLayout>

Также взгляните на этот ответ это довольно хорошо.

...