如何轻松地将 LinearLayout 转换为relativelayout
我有 4 个 LinearLayout
,我想将其转换为 RelativeLayout
。在这里使用我的 xml
作为我的首选格式:
- ImageButton
- ImageButton
- TextView
- Button
如何更改为 RelativeLayout
以始终显示第一个 ImageButton
在最顶部,始终在最底部显示 Button
,并在第一个 ImageButton
下方放置第二个 ImageButton
,其中 TextView 位于第二个 ImageButton 和常规 Button 之间?
谢谢!
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:gravity="center">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/image_view" />
<TextView
android:text="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/message" />
<Button
android:layout_gravity="center_horizontal"
android:layout_width="fill_parent"
android:textStyle="bold"
android:id="@+id/action_button"
android:selectAllOnFocus="false"
android:layout_height="100dip"
android:text="Click here to Crop"/>
</LinearLayout>
I have 4 LinearLayout
s that I would like to convert into RelativeLayout
s. Using my xml
here, I have, as my preferred format:
- ImageButton
- ImageButton
- TextView
- Button
How do I change to RelativeLayout
to always display the 1st ImageButton
on the very top, always display the Button
at the very bottom, and have the 2nd ImageButton
below the first ImageButton
, with the TextView
between the 2nd ImageButton
and the regular Button
?
Thanks!
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:gravity="center">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/image_view" />
<TextView
android:text="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/message" />
<Button
android:layout_gravity="center_horizontal"
android:layout_width="fill_parent"
android:textStyle="bold"
android:id="@+id/action_button"
android:selectAllOnFocus="false"
android:layout_height="100dip"
android:text="Click here to Crop"/>
</LinearLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您也可能需要查看此处和此处
also you may want to look here and here
如果您使用可以帮助您设置布局参数选项的 IDE,则可以非常轻松地构建relativelayout。
例如,您需要的是 android:layout_alignParentTop="true" 和 android:layout_below="@id/xxxxxxxx"
此链接将帮助您开始:
http://developer.android.com/guide/topics/ui/layout -objects.html
RelativeLayouts are very easy to build if you use an IDE that helps you with the layout parameter options.
What you need are for example android:layout_alignParentTop="true" and android:layout_below="@id/xxxxxxxx"
This link will get you started:
http://developer.android.com/guide/topics/ui/layout-objects.html