0

私が持っているもの: ScrollView、その中に LinearLayout

( orientation="vertical", layout_width="match_parent", layout_height="wrap_content")、

その中

ImageView

( layout_width="match_parent", layout_height="wrap_content") と

TextView.

私が欲しいもの: ImageView縦横比と数学の親の幅、および下のテキストを保持する必要がありますImageView

ImageView params:adjustViewBounds true/falseと allscaleTypeのさまざまな組み合わせを使用しましたが、必要なものを取得できません:

  1. scaleType centerCrop を使用する場合 - 画像がトリミングされている場合は上部と下部。
  2. scaleType center - 左右に空きスペースを使用する場合
  3. scaleType fitXY を使用すると、画像の縦横比が維持されません

画像の高さを高くすることはできません。どうすれば修正できますか?

4

1 に答える 1

2

これを試して:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ll_main"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    >
<LinearLayout
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:orientation="vertical"
       >
<ImageView
        android:layout_width="fill_parent"
        android:layout_height="100dp"
        android:id="@+id/iv"
        android:background="#f0f"
        />  
<TextView
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:text="Always work!!"
           android:gravity="center"
           android:textSize="26sp"
           />
</LinearLayout>
</ScrollView>

注:scaleType役に立たない場合は、android:background=""代わり に使用してみてくださいandroid:src=""

ここに画像の説明を入力

于 2013-04-11T11:06:56.383 に答える