Why is that that the textview with the id of textView1 and textView2 are not showing up but everything else is showing.
为什么textView1和textView2的id的textview没有显示,但其他所有内容都显示出来。
I tried adding the
我试过添加
android:layout_alignLeft="@+id/bus_data"
android:layout_below="@+id/bus_data"
but still it is not showing up. I dont know what is wrong with the xml
但它仍然没有出现。我不知道xml有什么问题
Here is the xml code:
这是xml代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_horizontal_margin"
tools:context=".MainActivity"
android:background="#545454" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/search_result_box"
android:background="@drawable/search_item_selector_stlye">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/bus_data"
android:background="@drawable/search_item_selector_stlye">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:id="@+id/stop_code_string"
android:text="@string/stop_code_string"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#2a2a2a"
android:textSize="10sp"
android:layout_gravity="center"
android:gravity="center" />
<TextView android:id="@+id/stop_code"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/stop_code_string"
android:padding="20dip"
android:textColor="#2a2a2a"
android:textSize="16sp"
android:textStyle="bold"
android:gravity="center"
android:background="@drawable/right_border_line_textview"
/>
</LinearLayout>
<View
android:layout_width="1dip"
android:layout_height="fill_parent"
android:background="#bdbdbd"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:id="@+id/stop_name_String"
android:text="@string/stop_name_string"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#2a2a2a"
android:textSize="10sp"
android:gravity="center"
android:paddingLeft="5dp"
/>
<TextView android:id="@+id/stop_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/stop_name_string"
android:paddingLeft="20dp"
android:paddingTop="10dp"
android:textColor="#2a2a2a"
android:textSize="16sp"
android:textStyle="bold"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/search_result_data_box"
android:background="@drawable/search_item_selector_stlye">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/bus_data"
android:layout_below="@+id/bus_data"
android:text="asdasdasdasdas" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/bus_data"
android:layout_below="@+id/bus_data"
android:text="asdasdasdasdas" />
</LinearLayout>
</LinearLayout>
2 个解决方案
#1
0
These TextView are in a Linearlayout. You only have below
and left
in RelartiveLayout. Please give your parent linearLayout the below an and Left parameters
这些TextView位于Linearlayout中。您只有在RelartiveLayout的下方和左侧。请给你的父母linearLayout下面的a和Left参数
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/search_result_data_box"
android:layout_alignLeft="@+id/bus_data"
android:layout_below="@+id/bus_data"
android:background="@drawable/search_item_selector_stlye">
I see that bus_data
is in LinearLayout too, so what you are planing to do does not work. Try other Methods or post a picture what kind of layout you want to achieve
我看到bus_data也在LinearLayout中,所以你要做的事情不起作用。尝试其他方法或发布图片您想要实现的布局类型
#2
0
Both TextView
seem to reference bus_data
as the id of the View
they need to align below and to the left to.
两个TextView似乎都引用bus_data作为它们需要在下方和左侧对齐的视图的id。
However they reference it by adding a new id (+id
).
但是他们通过添加新的id(+ id)来引用它。
They should probably only reference the existing id without attempting to create a new one.
他们应该只引用现有的id而不试图创建一个新的id。
See also: this SO thread for more info on the android:id
attribute.
另请参阅:此SO线程获取有关android:id属性的更多信息。
#1
0
These TextView are in a Linearlayout. You only have below
and left
in RelartiveLayout. Please give your parent linearLayout the below an and Left parameters
这些TextView位于Linearlayout中。您只有在RelartiveLayout的下方和左侧。请给你的父母linearLayout下面的a和Left参数
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/search_result_data_box"
android:layout_alignLeft="@+id/bus_data"
android:layout_below="@+id/bus_data"
android:background="@drawable/search_item_selector_stlye">
I see that bus_data
is in LinearLayout too, so what you are planing to do does not work. Try other Methods or post a picture what kind of layout you want to achieve
我看到bus_data也在LinearLayout中,所以你要做的事情不起作用。尝试其他方法或发布图片您想要实现的布局类型
#2
0
Both TextView
seem to reference bus_data
as the id of the View
they need to align below and to the left to.
两个TextView似乎都引用bus_data作为它们需要在下方和左侧对齐的视图的id。
However they reference it by adding a new id (+id
).
但是他们通过添加新的id(+ id)来引用它。
They should probably only reference the existing id without attempting to create a new one.
他们应该只引用现有的id而不试图创建一个新的id。
See also: this SO thread for more info on the android:id
attribute.
另请参阅:此SO线程获取有关android:id属性的更多信息。