0

線形レイアウトを使用してAndroidで次のデザインを設計したい ここに画像の説明を入力

次のコードを書きましたが、機能しませんでした

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"  android:layout_weight="1"
        android:layout_height="fill_parent" android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content" android:layout_weight="1" >

                <ImageView
                    android:id="@+id/imageView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@android:drawable/alert_dark_frame" />           
                    <LinearLayout android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:weightSum="2" >
                            <TextView
                                android:id="@+id/textView1"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content" android:layout_alignParentLeft="true"
                                android:text="TextView" android:layout_weight="1" />        
                            <TextView
                                android:id="@+id/textView2" android:layout_weight="1"
                                android:layout_width="wrap_content" 
                                android:layout_height="wrap_content" android:layout_alignParentRight="true"
                                android:text="TextView" />
                    </LinearLayout>                
                <TextView
                    android:id="@+id/textView3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="TextView" android:hint="TestData"/>
            </LinearLayout>            
</LinearLayout>

次のような出力が得られます

ここに画像の説明を入力

誰でも私を指摘できますか..どこに問題がありますか???

4

5 に答える 5

3
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@android:drawable/alert_dark_frame" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="vertical" >

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

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="dfasdfasdfasfasf" />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="right"
                android:text="07 DEc" />
        </LinearLayout>

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="dskfhasjkldfhadjklsfhadjklsfhajkldfhadjklsfhajklsfhajklsdfhajklsdfhajklsdfhajkldf" />
    </LinearLayout>

</LinearLayout>

これはうまくいくでしょう...:)

于 2012-12-06T13:14:18.310 に答える
0

これはあなたのために働くでしょう。

<?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"
    android:background="#ffffff"
    android:padding="5dip" >

    <ImageView
        android:id="@+id/icon"
        android:layout_width="70px"
        android:layout_height="50px"
        android:layout_marginRight="3dip"
        android:src="@drawable/ic_launcher" />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/toptext"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:maxLines="1"
                android:text="dsggsdggfsgf"
                android:textColor="#000000"
                android:textSize="16px"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/datetext"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:maxLines="1"
                android:text="1 dec 2012"
                android:textColor="#cccccc"
                android:textSize="12px"
                android:textStyle="bold" />
        </RelativeLayout>

        <TextView
            android:id="@+id/bottomtext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="dsggsdggfsgfwaffgdgafgggfdgfdgsfgfdgdfsgdfdsggsdggfsgfwaffgdgafgggfdgfdgsfgfdgdfsgdfdsggsdggfsgfwaffgdgafgggfdgfdgsfgfdgdfsgdfdsggsdggfsgfwaffgdgafgggfdgfdgsfgfdgdfsgdf"
            android:textColor="#696969"
            android:textSize="12px" />
    </LinearLayout>

</LinearLayout>
于 2012-12-06T13:08:26.110 に答える
0
   <?xml version="1.0" encoding="utf-8"?>
   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"  android:layout_weight="1"
    android:layout_height="fill_parent" android:orientation="vertical">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:weightSum="3" 
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:src="@android:drawable/alert_dark_frame" 
                android:layout_weight="2"/>           
                <LinearLayout android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:orientation="vertical" >
                        <LinearLayout android:layout_width="match_parent"
                             android:layout_height="wrap_content"
                             android:weightSum="3"
                             android:orientation="horizontal" >
                                <TextView
                                    android:id="@+id/textView1"
                                    android:layout_width="fill_parent"
                                    android:layout_height="wrap_content" 
                                    android:text="hfdfhfj" android:layout_weight="2" />        
                                <TextView
                                    android:id="@+id/textView2" android:layout_weight="1"
                                    android:layout_width="wrap_content" 
                                    android:layout_height="wrap_content"
                                    android:text="6 Dec 2012" />

                         </LinearLayout>
                         <LinearLayout android:layout_width="fill_parent"
                             android:layout_height="wrap_content">
                             <TextView
                                    android:id="@+id/textView3"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:text="fkjfkdsnfdsnfkdsn\nmnfkfknfkdf\nfknf" android:hint="TestData"/>
                         </LinearLayout>
                </LinearLayout>                

        </LinearLayout>            
   </LinearLayout>

このコードを試してください。まさにあなたが望むものです。

于 2012-12-06T13:09:19.817 に答える
0

これは機能するはずです。しかし、あなたが使用する場合はより良いでしょうRelativeLayout

<?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"
android:layout_weight="1"
android:background="@android:color/white"
android:orientation="horizontal" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@android:drawable/alert_dark_frame" />

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:weightSum="2" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="TextView" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="TextView" />
    </LinearLayout>

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="TestData"
        android:text="TextView" />
</LinearLayout>

</LinearLayout>
于 2012-12-06T12:57:36.660 に答える
0

次のように、最初のレベルでrelativelayoutを使用できると思います。

<relativelayout>
     <imageview align to parent top, left, bottom>
     <linearlayout align to parent to, right, right to image view>
          <textview1/>
          <textview2/>
     </linearlayout>
     <textview align to parent bottom, right, righto to image view, below linearlayout>
 </relativelayout>
于 2012-12-06T12:58:12.120 に答える