0

アプリに1つと1つImageViewのsがあり、以下に示すようなレイアウトが必要です。TextViewGallery

............................................-.
<ImageView>|     <TextView>      |<ImageView>|
..............................................
|                                            |
|                  Gallery                   |
|                                            |
|............................................|

ImageView私はテーブルレイアウトを持っていて、テキストの長さが短い場合に画面の右端のが動き続けることを除いて、上記のようにほぼデザインを取得しました。ImageViewテキストのサイズに関係なく、画面の左端と右端の'を固定したい。

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

    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_height="wrap_content" 
         android:layout_width="wrap_content">

         <TableRow>
              <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
                   android:id="@+id/imageL"
                   android:layout_width="fill_parent"
                   android:layout_height="fill_parent"  
                   android:layout_weight="1"
                   android:minHeight="30px"
                   android:minWidth="30px" />

              <TextView xmlns:android="http://schemas.android.com/apk/res/android"
                   android:id="@+id/title"
                   android:paddingLeft="10px"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content" 
                   android:layout_weight="3"
                   android:layout_gravity="center"
                   android:minHeight="30px"
                   android:minWidth="30px" />

               <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
                   android:id="@+id/imageR"
                   android:paddingLeft="10px"
                   android:layout_width="fill_parent"
                   android:layout_height="fill_parent"
                   android:layout_weight="1"
                   android:minHeight="30px"
                   android:minWidth="30px" />
          </TableRow> 
    </TableLayout>

    <Gallery xmlns:android="http://schemas.android.com/apk/res/android"
         android:id="@+id/gallery"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content" />
</LinearLayout>
4

3 に答える 3

0

これをTableLayoutタグに追加します。

android:shrinkcolumns="0,2" android:stretchColumns="1"

また、代わりにlayout_widthをfill_parentに変更することもできます。これにより、中央の列が引き伸ばされるようになります。

于 2011-02-15T14:19:06.353 に答える
0

それのようなもの。imgの幅と高さを静的にしたい場合は、android:layout_widthとandroid:layout_heightで設定できます。

<?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"
>
    <ImageView 
    android:id="@+id/firstImage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:src="@drawable/icon"
    />
    <TextView 
    android:id="@+id/someText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toLeftOf="@+id/secondImage"
    android:layout_toRightOf="@+id/firstImage"
    android:text="some mega text."
    android:gravity="center_horizontal"
    />
    <ImageView 
    android:id="@+id/secondImage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:src="@drawable/icon"
    />

</RelativeLayout>
于 2011-02-15T12:27:04.213 に答える
0

3つのアイテムすべてに等しい重みを使用します。問題は解決する必要があります。

android:layout_weight="1"

3つすべてが同じ面積を占めます。

于 2011-02-15T12:28:47.590 に答える