[英]Android layout issue with sibling of RelativeLayout
I add add LinearLayout with horizontal orientation to my Android layout, but unfortunately there is an error: id/title_dialog_text_view is not a sibling in the same RelativeLayout. 我在我的Android布局中添加了水平方向的LinearLineLayout,但是不幸的是出现了一个错误:id / title_dialog_text_view在同一个RelativeLayout中不是同级的。
I am trying to combine TextView and ProgressBar in horizontal not vertical line. 我正在尝试将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>
this error is because parent of TextView
and LinearLayout
are not same. 此错误是因为
TextView
和LinearLayout
父代不相同。 if you want to put TextView
and ProgressBar
horizontal , change their parent's orientation
to horizontal
如果要将
TextView
和ProgressBar
放置为水平,请将其父级的orientation
更改为horizontal
May this solves your problem : 也许这可以解决您的问题:
<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" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.