Height half fill_parent xml

丶灬走出姿态 提交于 2019-12-19 05:34:28

问题


How I can do with LinearLayout height half fill_parent in xml?

<LinearLayout android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:weightSum="1">
      <ImageView android:layout_height="fill_parent"
                 android:layout_width="0dp"
                 android:layout_weight="0.5"/>
</LinearLayout>

I would like do something similar with height.


回答1:


I just want have a half of screen with 1 linearLayout and half screen with other one

Try this

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="2"
    android:orientation="vertical" >

    <LinearLayout android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="#192832"></LinearLayout>

    <LinearLayout android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="#193222"></LinearLayout>


</LinearLayout>

Two linear layouts occupying half of the screen each.



来源:https://stackoverflow.com/questions/16748872/height-half-fill-parent-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!