首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >线性布局-内部线性布局不显示

线性布局-内部线性布局不显示
EN

Stack Overflow用户
提问于 2013-03-16 18:59:08
回答 1查看 572关注 0票数 0

Android 2.3.3

我正在尝试创建一个标题,考虑到以下想法

代码语言:javascript
复制
              Expression
 S.NO         Result    

  1.          1+2+3
              6

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

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

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

代码语言:javascript
复制
<?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%。有没有一种方法可以在没有嵌套权重的情况下创建它?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-03-16 19:13:32

终于明白了..。在经历了一些曲折和调整之后

代码语言:javascript
复制
<?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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15448436

复制
相关文章

相似问题

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