代码之家  ›  专栏  ›  技术社区  ›  Prabhat

Android布局帮助

  •  1
  • Prabhat  · 技术社区  · 15 年前

    我有一个列表视图,我必须设计一个用于适配器的行布局。布局是这样的。

    First column we have an icon on left most side. 
    Second column we have a string of about 4-30 characters 
    Last column, the date with time. 
    

    3 回复  |  直到 14 年前
        1
  •  0
  •   Sameer Segal    15 年前

    以谢尔盖的代码为基础(我相信这并不能完全解决问题)。我已经指定了比例1/2:1/1:1/3(对于图像:字符串:日期);

    <?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="wrap_content" >
        <ImageView
            android:src="@drawable/image"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content"
            android:layout_weight="2" />    
        <TextView  
            android:text="Lorem ipsum dolor sit amet, consectetuer adipiscing elit"
            android:gravity="center_horizontal"
            android:layout_weight="1"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" />
        <TextView
            android:text="23.10.2010 23:34:52"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="3" />
    </LinearLayout>
    
        2
  •  1
  •   Sergey Glotov Nitesh Khosla    15 年前

    尝试此布局

    <?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="fill_parent" >
        <ImageView
            android:src="@drawable/image"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" />    
        <TextView  
            android:text="Lorem ipsum dolor sit amet, consectetuer adipiscing elit"
            android:gravity="center_horizontal"
            android:layout_weight="1.0"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" />
        <TextView
            android:text="23.10.2010 23:34:52"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>