本文介绍了RelativeLayout的和高度的百分比。无法使用layout_below和layout_weight的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

萨吕!我有问题的RelativeLayout它在那里孩子们可以使用layout_below和layout_weight设置其百分比高度。

Salut! I have problem with relativelayout where its children could use layout_below and layout_weight to set its percentage height.

例如。我们有相对布局和它里面我们有textviews 3线性布局。现在,我想他们(linearlayouts)相对布局的总高度的高度25,50,25%的3集。我怎么能acomplish呢?

For example. We have relative layout and inside of it we have 3 linear layouts with textviews. Now, I would like to set for 3 of them (linearlayouts) 25,50,25 % of height of total height of relative layout. How could I acomplish it?

我找到了解决方案,weight_sum和和的RelativeLayout(CLICK),但它不使用layout_below。

I found solution for weight_sum and and relativelayout (CLICK) but it doesn't use layout_below.

请帮忙。我试图添加所有linearlayouts内额外的LinearLayout但我无法使用layout_below。

Please help. I tried to add additional linearlayout inside of all linearlayouts but then I am unable use layout_below.

下面是概念PIC的想法:

Here is concept pic idea:

下面是我的code:

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/linlay_leftcol_notification_header" >

<LinearLayout
android:id="@+id/linlay_leftcol_clock_theday"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >

<TextView
    android:id="@+id/tv_theday"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="@string/theday"
    android:textColor="#FFFFFF" />
</LinearLayout>

<LinearLayout
android:id="@+id/linlay_leftcol_clock_thetime"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linlay_leftcol_clock_theday" >

<TextView
    android:id="@+id/tv_thetime"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="@string/thetime"
    android:textColor="#FFFFFF" />
</LinearLayout>

<LinearLayout
android:id="@+id/linlay_leftcol_clock_thenumber_themonth_theyear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linlay_leftcol_clock_thetime" >

<TextView
    android:id="@+id/tv_thenumberofday_themonth_theyear"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="@string/thenumberofday_themonth_theyear"
    android:textColor="#FFFFFF" />
</LinearLayout>
</RelativeLayout>

P.S。请原谅语法,因为我仍然在学习这门语言。我搜索后前解决方案。

P.S. Please pardon the grammar, because I'm still learning this language. I've searched for solution before post.

推荐答案

试试这个...希望这能解决的目的..: - )

Try this... Hope this solves the purpose.. :-)

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

    <RelativeLayout
        android:layout_weight="1"
        android:background="#ffff00"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <TextView
            android:id="@+id/textView0"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:text="Hello 1"
            android:textColor="#000000"
            android:textSize="15dp" />
    </RelativeLayout>

    <RelativeLayout
        android:layout_weight="2"
        android:background="#00ffff"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <TextView
            android:id="@+id/textView1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:text="Hello 2"
            android:textColor="#000000"
            android:textSize="15dp" />
    </RelativeLayout>

    <RelativeLayout
        android:layout_weight="1"
        android:background="#ffff00"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <TextView
            android:id="@+id/textView2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:text="Hello 3"
            android:textColor="#000000"
            android:textSize="15dp" />
    </RelativeLayout>
</LinearLayout>

这篇关于RelativeLayout的和高度的百分比。无法使用layout_below和layout_weight的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 07:07