如何在android中设置Widgets的布局权重?

时间:2016-05-13 05:36:11

标签: android android-layout

您好我是Android的新手,在我的应用程序中,我想设置Textviews,就像下面的图像一样,为此,我编写了下面的代码,然后所有Textviews宽度都变得相等。

但我想将Textviews设置为我的下图。

请帮帮我。

代码: -

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Color"/>

        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:text=":"/>

        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:background="@android:color/holo_red_dark"
          />

    </LinearLayout>

</LinearLayout>

enter image description here

2 个答案:

答案 0 :(得分:1)

  

您需要将\n传递给1

strlen(source) + 19

答案 1 :(得分:0)

  

2:1:7的比例可能会更好

"
相关问题