Android 相对布局的麻烦
我对相对布局很陌生,我正在努力解决它们;)
我想做的是: http://pineapple.cc/plan.jpg
但我得到的是: http://pineapple.cc/result.jpg
这是我的代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/list_poi_image"
android:src="@drawable/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/list_poi_ll"
android:background="#000000" />
<LinearLayout
android:id="@+id/list_poi_ll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:orientation="vertical">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView android:id="@+id/list_poi_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/list_poi_date_created"
android:text="Name"/>
<TextView android:id="@+id/list_poi_date_created"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Date created"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView android:id="@+id/list_poi_description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/list_poi_date_planned"
android:text="Description"/>
<TextView android:id="@+id/list_poi_date_planned"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Date planned"/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
我做错了什么? ?
感谢您的帮助 !!
I am quite new to relative layouts and I am struggling with them ;)
What I am trying to do is that:
http://pineapple.cc/plan.jpg
But what I get is that:
http://pineapple.cc/result.jpg
This is my code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/list_poi_image"
android:src="@drawable/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/list_poi_ll"
android:background="#000000" />
<LinearLayout
android:id="@+id/list_poi_ll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:orientation="vertical">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView android:id="@+id/list_poi_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/list_poi_date_created"
android:text="Name"/>
<TextView android:id="@+id/list_poi_date_created"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Date created"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView android:id="@+id/list_poi_description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/list_poi_date_planned"
android:text="Description"/>
<TextView android:id="@+id/list_poi_date_planned"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Date planned"/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
What am I doing wrong ???
Thanks for your help !!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想充分利用RelativeLayouts,则无需在其他RelativeLayouts/LinearLayouts 中使用RelativeLayouts/LinearLayouts。
有关如何使用RelativeLayouts的示例,请参见:
http://developer.android .com/resources/tutorials/views/hello-relativelayout.html
http://android-developers.blogspot.com/2009/02 /android-layout-tricks-1.html
总之,您正在寻找以下内容:
请注意,硬编码字符串位于其中,使您能够查看文本。确保删除这些并使用 strings.xml 文件。
If you are wanting to use RelativeLayouts to the best of there abilities, there is no need to have RelativeLayouts/LinearLayouts within other RelativeLayouts/LinearLayouts.
For examples of how to use RelativeLayouts look at:
http://developer.android.com/resources/tutorials/views/hello-relativelayout.html
http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html
In terns of what your looking for the following is what you are looking for:
Please note that the hard-coded Strings are in there to enable you to see the text. Ensure you remove these and use a strings.xml file.