java文本视图未显示在linearLayout中
为什么id为textView1和textView2的textview没有显示,但其他所有内容都显示出来了
我试着添加
安卓:layout_alignLeft="@+id/bus_data"
安卓:layout_below="@+id/bus_data"
但它仍然没有出现。我不知道xml有什么问题
以下是xml代码:
<RelativeLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:tools="http://schemas.安卓.com/tools"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:paddingBottom="@dimen/activity_vertical_margin"
安卓:paddingLeft="@dimen/activity_horizontal_margin"
安卓:paddingRight="@dimen/activity_horizontal_margin"
安卓:paddingTop="@dimen/activity_horizontal_margin"
tools:context=".MainActivity"
安卓:background="#545454" >
<LinearLayout
安卓:layout_width="fill_parent"
安卓:layout_height="wrap_content"
安卓:orientation="horizontal"
安卓:id="@+id/search_result_box"
安卓:background="@drawable/search_item_selector_stlye">
<LinearLayout
安卓:layout_width="fill_parent"
安卓:layout_height="wrap_content"
安卓:orientation="horizontal"
安卓:id="@+id/bus_data"
安卓:background="@drawable/search_item_selector_stlye">
<LinearLayout
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:orientation="vertical">
<TextView 安卓:id="@+id/stop_code_string"
安卓:text="@string/stop_code_string"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:textColor="#2a2a2a"
安卓:textSize="10sp"
安卓:layout_gravity="center"
安卓:gravity="center" />
<TextView 安卓:id="@+id/stop_code"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:text="@string/stop_code_string"
安卓:padding="20dip"
安卓:textColor="#2a2a2a"
安卓:textSize="16sp"
安卓:textStyle="bold"
安卓:gravity="center"
安卓:background="@drawable/right_border_line_textview"
/>
</LinearLayout>
<View
安卓:layout_width="1dip"
安卓:layout_height="fill_parent"
安卓:background="#bdbdbd"
/>
<LinearLayout
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:orientation="vertical">
<TextView 安卓:id="@+id/stop_name_String"
安卓:text="@string/stop_name_string"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:textColor="#2a2a2a"
安卓:textSize="10sp"
安卓:gravity="center"
安卓:paddingLeft="5dp"
/>
<TextView 安卓:id="@+id/stop_name"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:text="@string/stop_name_string"
安卓:paddingLeft="20dp"
安卓:paddingTop="10dp"
安卓:textColor="#2a2a2a"
安卓:textSize="16sp"
安卓:textStyle="bold"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
安卓:layout_width="fill_parent"
安卓:layout_height="wrap_content"
安卓:orientation="vertical"
安卓:id="@+id/search_result_data_box"
安卓:background="@drawable/search_item_selector_stlye">
<TextView
安卓:id="@+id/textView1"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_alignLeft="@+id/bus_data"
安卓:layout_below="@+id/bus_data"
安卓:text="asdasdasdasdas" />
<TextView
安卓:id="@+id/textView2"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_alignLeft="@+id/bus_data"
安卓:layout_below="@+id/bus_data"
安卓:text="asdasdasdasdas" />
</LinearLayout>
</LinearLayout>
# 1 楼答案
这两个
TextView
似乎都引用bus_data
作为View
的id,它们需要在下方和左侧对齐,以进行编辑然而,他们通过添加一个新id(
+id
)来引用它他们可能只引用现有id,而不尝试创建新id
另请参见:thisSO thread以了解有关
android:id
属性的更多信息# 2 楼答案
这些文本视图位于线性布局中。在RelartivelLayout中只有
below
和left
。 请为您的家长线性布局提供以下参数和左参数我看到
bus_data
也在线性布局中,所以您计划做的事情不起作用。尝试其他方法,或者发布一张你想要实现的布局的图片