首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将FrameLayout指定为父RelativeLayout的一半

将FrameLayout指定为父RelativeLayout的一半
EN

Stack Overflow用户
提问于 2015-08-02 13:18:21
回答 3查看 5K关注 0票数 4

我在一个相对的布局中有一个框架布局,其他的东西都在它下面。如何使这个帧布局占据整个屏幕的一半?

我试过体重,但这改变不了什么。

代码语言:javascript
运行
复制
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/mainLayoutStyle">

<FrameLayout 
       android:id="@+id/codeLayout"
       style="@style/codeLayoutLargeStyle">   

        <TextView 
            android:id="@+id/DisplayTextView"
            style="@style/DisplayTextViewLargeStyle"/>
</FrameLayout>
......
.....
   <LinearLayout 
EN

Stack Overflow用户

发布于 2015-08-02 13:39:32

Marcin是对的,只有当您将父布局作为线性布局,而要使框架布局覆盖半屏幕时,权重属性才会有效,您必须将两个布局作为该线性布局的子布局,并将其除以相等的权重。

e.g

代码语言:javascript
运行
复制
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<FrameLayout
    android:id="@+id/you_frame_layout"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:background="#00ff00">

</FrameLayout>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">

</RelativeLayout>

希望这对你有帮助。

票数 0
EN
查看全部 3 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31772274

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档