3

このレイアウト XML があり、可能であれば 2 行目の ImageView を拡大して行ビューに合わせ、最初の行の textview を画面の左側に固定し、中央に配置する必要があります。ImageView は、カメラから取得した画像で満たされています。助けていただければ幸いです。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
>

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_gravity="center"
    android:layout_weight="1"
    android:stretchColumns="*" >

    <TableRow android:id="@+id/tableRow1" >

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

            <TextView
                android:id="@+id/textView1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_gravity="center"
                android:text="Set Your Personal Information Here"
                android:textAppearance="?android:attr/textAppearanceMedium" />
        </LinearLayout>
    </TableRow>

    <TableRow android:id="@+id/tableRow2" >

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

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </LinearLayout>
    </TableRow>

    <TableRow android:id="@+id/tableRow3" >

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="horizontal" >

            <QuickContactBadge
                android:id="@+id/quickContactBadge1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="left" />

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

                <TextView
                    android:id="@+id/textView2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Name"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

                <TextView
                    android:id="@+id/textView3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Gender"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

                <TextView
                    android:id="@+id/textView4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Credits"
                    android:textAppearance="?android:attr/textAppearanceMedium" />
            </LinearLayout>
        </LinearLayout>
    </TableRow>
</TableLayout>

4

1 に答える 1

13

@Brosa がコメントで述べたように、android:scaleType="fitXY"属性を使用します。

android:scaleType解決策を見つけたので、今後のヘルプのために、さまざまなオプションについて簡単に説明するためにこの回答を書いています。

この属性にはいくつかのオプションがあります。彼らです

  1. マトリックス
  2. フィットXY
  3. 適合開始
  4. フィットセンター
  5. フィットエンド
  6. 中心
  7. センタークロップ
  8. センターインサイド

これは、ドキュメントからの簡単な説明です

1. マトリックス
描画時に画像マトリックスを使用してスケールします。

2. fitXY
src が dst と正確に一致するように、X と Y で画像を個別にスケーリングします。これにより、src のアスペクト比が変更される場合があります。

3. fitStart
元の src の縦横比を維持しながらも、src が dst 内に完全に収まるようにスケールを計算することにより、画像をスケーリングします。少なくとも 1 つの軸 (X または Y) が正確に適合します。START は、結果を dst の左端と上端に揃えます。

4. fitCenter
元の src の縦横比を維持しながら、src が dst 内に完全に収まるようにスケールを計算することにより、画像をスケーリングします。少なくとも 1 つの軸 (X または Y) が正確に適合します。結果は dst の中央に配置されます。

5. fitEnd
元の src の縦横比を維持しながら、src が dst 内に完全に収まるようにするスケールを計算することにより、画像をスケーリングします。少なくとも 1 つの軸 (X または Y) が正確に適合します。END は、結果を dst の右端と下端に揃えます。

6. center
イメージをビューの中央に配置しますが、スケーリングは実行しません。

7. centerCrop
画像の両方の寸法 (幅と高さ) がビューの対応する寸法 (パディングを引いたもの) 以上になるように、画像を均一にスケーリングします (画像の縦横比を維持します)。

8. centerInside
画像の両方の寸法 (幅と高さ) がビューの対応する寸法 (パディングを引いたもの) 以下になるように、画像を均一にスケーリングします (画像の縦横比を維持します)。

于 2013-04-20T03:44:17.837 に答える