将relativelayout放置在另一个LinearLayout内的LinearLayout下面
我试图将 RelativeLayout
放置在嵌套在另一个 LinearLayout
内的 LinearLayout
下面,但它不起作用。
我有什么办法可以做到这一点吗?
我需要保留设置权重的能力以及将布局(具有一些透明背景)放置在另一个布局之上的能力。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/relative"
android:layout_width="wrap_content" android:layout_height="fill_parent" >
<LinearLayout android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center_horizontal" android:orientation="vertical" android:weightSum="800">
<LinearLayout android:layout_alignParentRight="true" android:layout_width="fill_parent" android:id="@+id/infoCanso" android:orientation="vertical" android:background="@drawable/black_glossy_bg_iphone" android:gravity="center_vertical|center_horizontal" android:layout_height="0dip" android:layout_weight="90">
</LinearLayout>
<LinearLayout android:id="@+id/albumBG" android:layout_width="wrap_content" android:layout_below="@+id/infoCanso" android:layout_height="0dip" android:layout_weight="482">
</LinearLayout>
<LinearLayout android:id="@+id/linearLayout1" android:background="#80ffffff" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="90">
</LinearLayout>
<LinearLayout android:layout_width="fill_parent" android:layout_height="0dip" android:id="@+id/LinearLayout01" android:layout_weight="100" android:background="#ffffff">
</LinearLayout>
</LinearLayout>
<RelativeLayout android:layout_width="fill_parent" android:layout_height="50dip" android:id="@+id/volumeBar" android:background="#80000000" android:gravity="center" android:layout_below="@+id/infoCanso">
</RelativeLayout>
</RelativeLayout>
I'm trying to place a RelativeLayout
below a LinearLayout
that is nested inside another LinearLayout
and it's not working.
Is there any way I can do that?
I need to keep the ability of settings weights and the ability of placing a Layout (with some transparent background) above another Layout.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/relative"
android:layout_width="wrap_content" android:layout_height="fill_parent" >
<LinearLayout android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center_horizontal" android:orientation="vertical" android:weightSum="800">
<LinearLayout android:layout_alignParentRight="true" android:layout_width="fill_parent" android:id="@+id/infoCanso" android:orientation="vertical" android:background="@drawable/black_glossy_bg_iphone" android:gravity="center_vertical|center_horizontal" android:layout_height="0dip" android:layout_weight="90">
</LinearLayout>
<LinearLayout android:id="@+id/albumBG" android:layout_width="wrap_content" android:layout_below="@+id/infoCanso" android:layout_height="0dip" android:layout_weight="482">
</LinearLayout>
<LinearLayout android:id="@+id/linearLayout1" android:background="#80ffffff" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="90">
</LinearLayout>
<LinearLayout android:layout_width="fill_parent" android:layout_height="0dip" android:id="@+id/LinearLayout01" android:layout_weight="100" android:background="#ffffff">
</LinearLayout>
</LinearLayout>
<RelativeLayout android:layout_width="fill_parent" android:layout_height="50dip" android:id="@+id/volumeBar" android:background="#80000000" android:gravity="center" android:layout_below="@+id/infoCanso">
</RelativeLayout>
</RelativeLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要确保您的权重总计为 100。执行您正在做的操作的一个简单方法是将宽度声明为“0dp”,然后使用您的权重来控制布局的大小。
我在这篇文章中描述了类似的内容,
祝你好运!
You need to make sure your weights add up to 100. An easy way to do what you're doing is to declare your widths as "0dp" and then use your weights to control the size of your layouts.
I described something similar in this post
Good luck!
这可以使用特定布局的属性layout_gravity来完成,
转到relativeLayout中的XML,将属性layout_gravity设置为“TOP”,如下所示 android:layout_gravity="top"
并将线性布局layout_gravity改为android:layout_gravity =“bottom”
记住setGravity和layout_gravity是不同的东西!
这可以使用 XMl 来完成,但我不知道代码方面。
希望我回答了你的问题
谢谢
This can be done using the property layout_gravity of the specific layout,
Go to the XML in relativeLayout set the property layout_gravity to 'TOP' like this android:layout_gravity="top"
and to the linearlayout layout_gravity to android:layout_gravity="bottom"
remember the setGravity and layout_gravity are different things !
This can be done using XMl but i dont know in code wise .
Hope i answered your question
Thanx