2013-07-17 69 views
2

如何用這樣的方式創建佈局image. 50%的文本和50%的其餘部分除以imageview textview和imageview我該怎麼做?Android如何劃分半屏?

請幫幫我。我想創建像這個圖像的屏幕請幫助我。

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/db1_root" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:weightSum="6" 
    android:background="#333333" > 


    <LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="#000000" 
    android:layout_weight="0" 
    android:weightSum="1.5" 
    android:layout_marginBottom="1dp" 
    android:orientation="horizontal" > 

    <LinearLayout 

    android:layout_marginRight="15dip" 
    android:layout_marginLeft="15dp" 
    android:layout_height="wrap_content" 
    android:layout_width="0dip" 
    android:background="@drawable/layoutborder" 
    android:layout_marginBottom="1dp" 
    android:layout_marginTop="1dp" 
    android:layout_weight="0.8" 
    android:orientation="vertical" > 


    <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.4" 
      android:paddingLeft="1dip" 
      android:src="@drawable/ic_launcher" /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="20dp" 
     android:paddingTop="5dp" 
     android:textSize="10dip" 
     android:text=CONTAINS" 
     android:textColor="#FFffff" /> 


     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.4"  
      android:paddingLeft="1dip" 
      android:src="@drawable/ic_launcher" /> 
     </LinearLayout> 

      <TextView 
      android:id="@+id/imageView1" 
      android:layout_width="0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.7" 
      android:paddingLeft="1dip" 
      android:text="kurdfgkjdfuhfudshfkdshfdfhs 
kdjhfjdshfkjdshfkdshfkshjdhfskjhfksdhfksjhfkjsdhfkjsdhfk 
jshfshfshfdshdfshdkjfhsafkjsahdfksahdf" /> 


    </LinearLayout> 


</LinearLayout> 

回答

1

嘗試

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/db1_root" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#333333" 
    android:orientation="horizontal" > 

    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_marginBottom="1dp" 
     android:layout_marginLeft="15dp" 
     android:layout_marginRight="15dp" 
     android:layout_marginTop="1dp" 
     android:layout_weight="1" 
     android:background="@color/blue" 
     android:orientation="vertical" > 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="0.4" 
      android:paddingLeft="1dp" 
      android:src="@drawable/login_down" /> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="20dp" 
      android:layout_weight="0.2" 
      android:paddingTop="5dp" 
      android:text="CONTAINS" 
      android:textColor="#FFffff" 
      android:textSize="10dip" /> 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="0.4" 
      android:paddingLeft="1dp" 
      android:src="@drawable/login_button" /> 
    </LinearLayout> 

    <TextView 
     android:id="@+id/imageView1" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:paddingLeft="1dp" 
     android:text="kurdfgkjdfuhfudshfkdshfdfhs 
    kdjhfjdshfkjdshfkdshfkshjdhfskjhfksdhfksjhfkjsdhfkjsdhfk 
    jshfshfshfdshdfshdkjfhsafkjsahdfksahdf" /> 

</LinearLayout> 
1

使用作爲最小的佈局可能會在快速渲染幫助。嘗試下面的代碼。

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

    <ImageView 
     android:id="@+id/imgMainImage" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/txtsubImgTitle" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:layout_toLeftOf="@+id/textView1" 
     android:src="@drawable/ic_launcher" /> 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:text="TextView" /> 

    <ImageView 
     android:id="@+id/imgSubImg" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignRight="@+id/imgMainImage" 
     android:src="@drawable/ic_launcher" /> 

    <TextView 
     android:id="@+id/txtsubImgTitle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/imgSubImg" 
     android:layout_alignParentLeft="true" 
     android:layout_marginBottom="16dp" 
     android:text="TextView" /> 

    </RelativeLayout>