2014-11-18 3 views
0

Я добавляю LinearLayout с горизонтальной ориентацией на мой макет Android, но, к сожалению, есть ошибка: id/title_dialog_text_view не является родным братом в том же RelativeLayout.Проблема с раскладкой Android с родным братом RelativeLayout

Я пытаюсь объединить TextView и ProgressBar в горизонтальной не вертикальной линии.

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_below="@+id/title_dialog_text_view" 
     android:layout_marginTop="6dp" 
     android:layout_marginLeft="6dp" 
     android:layout_marginRight="6dp" 
     android:paddingBottom="20dp" 
     android:gravity="center_horizontal" 
     android:orientation="vertical"> 
     <TextView 
      android:id="@+id/title_dialog_text_view" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:padding="10dp" 
      android:text="" 
      android:textSize="18sp"/> 
     <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <ProgressBar 
      android:id="@+id/pb_loading" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      style="@android:style/Widget.ProgressBar.Small"/> 
     <TextView 
      android:id="@+id/text_dialog_text_view" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_centerInParent="true" 
      android:gravity="center" 
      android:layout_margin="20dp" 
      android:lineSpacingExtra="6dp" 
      android:text="" 
      android:textSize="16sp"/> 
    </LinearLayout> 
    </LinearLayout> 
</RelativeLayout> 
+0

андроида: layout_below = "@ + идентификатор/title_dialog_text_view" - The View title_dialog_text_view находится внутри линейной компоновки. Поэтому вы не можете разместить родительский макет ниже детского макета. Пожалуйста, удалите эту строку. – Prem

ответ

0

эта ошибка, потому что родитель TextView и LinearLayout не являются одинаковыми. если вы хотите поставить TextView и ProgressBar горизонтальный, изменять их родителя orientation к horizontal

+0

, если он не решает вашу проблему, объясните больше для дальнейших действий. –

0

Пусть это решает проблему:

<ProgressBar 
    android:id="@+id/pb_loading" 
    style="@android:style/Widget.ProgressBar.Small" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_margin="20dp" /> 

<TextView 
    android:id="@+id/text_dialog_text_view" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_margin="20dp" 
    android:gravity="center" 
    android:text="" 
    android:textSize="16sp" /> 
Смежные вопросы