【问题标题】:Linear Layout - Inner Linear Layout doesn't get displayed线性布局 - 内部线性布局不显示
【发布时间】:2013-03-16 19:13:32
【问题描述】:

Android 2.3.3

我正在尝试创建一个带有以下想法的标题

              Expression
 S.NO         Result    

  1.          1+2+3
              6

  2.          2+3-4
              1
  .....

数据从数据库填充到列表视图中。我正在尝试为列表视图的标题部分创建一个 XML。 (SNO、表达式、结果)。

这是我正在使用的 XML...

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    android:paddingBottom="5dp"
    android:paddingTop="5dp" >


    <LinearLayout
        android:id="@+id/ll1"
        android:layout_width="0dip"
        android:layout_height="match_parent"
        android:layout_weight="0.10"
        android:orientation="horizontal" >

        <TextView
        android:id="@+id/txtView_History_Count"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="0.10"
        android:text="Number"
        android:textColor="#FFFFFF"
        android:textSize="22dp" />

    </LinearLayout>

    <LinearLayout
        android:id="@+id/ll2"
        android:layout_width="0dip"
        android:layout_height="match_parent"
        android:layout_weight="0.90"
        android:orientation="horizontal" > //If I change this to Vertical, 
                                           //the Output is not displayed

        <TextView
            android:id="@+id/txtView_History_Result"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="0.50"
            android:textSize = "22dp"
            android:text="Result"
            android:textColor="#316DA2" />

        <TextView
            android:id="@+id/txtView_History_Expression"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="0.50"
            android:text="Expression"
            android:textColor="#FFFFFF"
            android:textSize="15dp" />

    </LinearLayout>

</LinearLayout>

如果我将第二个内部布局的方向更改为垂直,则不会显示文本。出了什么问题?

另外,我希望第一个布局占总可用空间的 10% (android:layout_weight="0.10"),第二个布局占 90% (android:layout_weight="0.90")。然后,第二个布局中的文本视图应该占第二个布局中可用空间的 50%。有没有办法在没有嵌套权重的情况下创建它?

【问题讨论】:

  • 将父线性布局方向更改为垂直。
  • 但这将使表达式和结果归入 SNO。我希望他们并排。

标签: android android-linearlayout


【解决方案1】:

终于搞定了..经过一些曲折和调整

<?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="wrap_content"
    android:orientation="horizontal"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    android:paddingBottom="5dp"
    android:paddingTop="5dp" >


        <TextView
        android:id="@+id/txtView_History_Count"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="0.20"
        android:text="Number"
        android:textColor="#FFFFFF"
        android:textSize="22dp" />



    <LinearLayout
        android:id="@+id/ll2"
        android:layout_width="0dip"
        android:layout_height="match_parent"
        android:layout_weight="0.80"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/txtView_History_Result"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            android:textSize = "22dp"
            android:text="Result"
            android:textColor="#316DA2" />

        <TextView
            android:id="@+id/txtView_History_Expression"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            android:text="Expression"
            android:textColor="#FFFFFF"
            android:textSize="15dp" />

    </LinearLayout>

</LinearLayout>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-26
    • 2016-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多