简体   繁体   English

从底部30%创建相对布局

[英]Create a Relative layout at 30 % from bottom

I am having an imageView below which I need to create a RelativeLayout 2 that should be 70% from top and 30% from bottom and RelativeLayout from 30% top(ie at postion 30% as per screen resolution) and 70% bottom. 我在下面有一个imageView ,我需要创建一个RelativeLayout 2 ,该RelativeLayout 2应该是顶部的70%,底部的30%,RelativeLayout的顶部是30%(即,按屏幕分辨率,位置为30%),底部是70%。 Any inputs on how this needs to be implemented. 关于如何实现的任何输入。

<RelativeLayout 1>
<ImageView1>
<RelativeLayout 2>
<TextView 1>
<ImageView 2>
.
.
.
</RelativeLayout 2>
</RelativeLayout 1>
<LinearLayout
...
layout_height="fill_parent"
orientation="vertical"
weightSum="100">
  <LinearLayout
   layout_width="fill_parent"
   layout_height="0dp"
   layout_weight="70"
  >
  </LinearLayout>
  <RelativeLayout
   layout_width="fill_parent
   layout_height="0dp"
   layout_weight="30">
  </RelativeLayout
</LinearLayout>

It's just a draft but i hope you do understand. 这只是草稿,但我希望您能理解。

Use this in each layout to set a margin by dp to each other layout 在每个布局中使用此选项可以通过dp彼此设置边距

android:layout_marginTop="10dip"
// can be marginBottom, etc

The sample below just does what you need programatically. 下面的示例正是通过编程来满足您的需求。 I have used a fixed size of (140,398). 我使用了固定大小(140,398)。

LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(140, 398);
        layoutParams.setMargins(24, 0, 24, 0);
        layout.addView(layoutParams);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM