简体   繁体   English

如何以初始高度为fill_parent降低linearLayout的高度

[英]How to decrease the height of a linearLayout with initial height as fill_parent

What I am trying to achieve is to implement a typical texting screen, where I have a LinearLayout initially occupying the whole screen by setting the height to be fill_parent, except a RelativeLayout containing an EditText at the bottom of the screen using android:layout_alignParentBottom. 我想要实现的是实现一个典型的文本屏幕,其中我将LinearLayout最初通过将高度设置为fill_parent来占据整个屏幕,除了RelativeLayout在屏幕底部使用android:layout_alignParentBottom包含EditText之外。

Now, I need to display an extra RelativeLayout at the bottom of the small RelativeLayout, which should reduce the height of the LinearLayout, and push the original RelativeLayout up. 现在,我需要在小RelativeLayout的底部显示一个额外的RelativeLayout,这将减小LinearLayout的高度,并向上推原始的RelativeLayout。

Please advise what is the best way to achieve the above scenario. 请告知实现上述情况的最佳方法是什么。 Thank you. 谢谢。

I find easier the use of RelativeLayout for cases like this. 对于这种情况,我发现使用RelativeLayout更容易。

  • You can define a RelativeLayout as a container of all of them and place the others inside it. 您可以将RelativeLayout定义为所有容器的容器,然后将其他容器放置在其中。
  • Set your LinearLayout height to "match_parent" 将您的LinearLayout高度设置为“ match_parent”
  • Place the EditText below the LinearLayout; 将EditText放置在LinearLayout下面; and the RelativeLayout, below the EditText; 和EditText下方的RelativeLayout; using android:layout_below 使用android:layout_below

Good luck friend! 祝你好运的朋友!

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

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