2014-11-07 3 views
0

У меня есть этот код ниже. Я хочу, чтобы результат был рядом. что мне делать?Как разместить текстовое изображение рядом?

<TextView 
    android:id="@+id/textView29" 
    android:text="Number of guest(s) : " 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_toLeftOf="@+id/textView26" 
    android:textAppearance="?android:attr/textAppearanceMedium" /> 

    <TextView 
    android:id="@+id/textView27" 
    android:layout_width="50dp" 
    android:layout_height="wrap_content" 
    android:layout_toRightOf="@+id/textView29" 
    android:textAppearance="?android:attr/textAppearanceMedium" /> 

ответ

0

Вы можете заключить текст мнения в линейной компоновке, как так

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

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

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="TextView" /> 

     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="TextView" /> 

    </LinearLayout> 

</LinearLayout> 
+0

Я сделал это, но он все еще не работает. –

+0

Не могли бы вы разместить свой текущий xml-файл? – Galax

+0

извините ... моя ошибка ... это работает! спасибо ... :) –

1

Вы можете добавить их в новый суб макета «линейной компоновки» и использовать Android: ориентация = «горизонтальные»

0

Это даст вам наш желаемый результат, я добавил второй макет, который, надеюсь, поможет вам понять, как использовать макеты, я также включил туда, где вы можете вырезать ту часть, которая вам не нужна.

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

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

      <TextView 
       android:id="@+id/textView29" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_toLeftOf="@+id/textView26" 
       android:text="Number of guest(s) : " 
       android:textAppearance="?android:attr/textAppearanceMedium" /> 

      <TextView 
       android:id="@+id/textView27" 
       android:layout_width="50dp" 
       android:layout_height="wrap_content" 
       android:layout_toRightOf="@+id/textView29" 
       android:textAppearance="?android:attr/textAppearanceMedium" /> 
     </LinearLayout> 
//Below not needed 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 

      <TextView 
       android:id="@+id/textView1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_toLeftOf="@+id/textView26" 
       android:text="Number of guest(s) : " 
       android:textAppearance="?android:attr/textAppearanceMedium" /> 

      <TextView 
       android:id="@+id/textView2" 
       android:layout_width="50dp" 
       android:layout_height="wrap_content" 
       android:layout_toRightOf="@+id/textView29" 
       android:textAppearance="?android:attr/textAppearanceMedium" /> 
     </LinearLayout> 
//Above not needed 
    </LinearLayout> 
Смежные вопросы