1

同様の質問を見て答えを使用しましたが、それらを1つTextViewにまとめandroid:drawableTop=て配置すると、非常に奇妙に表示されます。現在のところ、テキストの上に画像を重ねるだけです。

オリジナル

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Navigation" >

    <ImageView
        android:id="@+id/logo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:contentDescription="@string/logo_name"
        android:src="@drawable/generic_logo" />

    <TextView
        android:id="@+id/about"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/about"
        android:textSize="55sp"
        android:onClick="onClick"
        android:clickable="true" />

</LinearLayout>

コンパウンド付き

    <TextView
        android:id="@+id/about"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/about"
        android:textSize="55sp"
        android:onClick="onClick"
        android:clickable="true"
        android:drawableTop="@drawable/generic_logo" />

</LinearLayout>

化合物は、エミュレートされたAndroidのパラメーターを超えて画像を拡大します。どうすればこれを修正し、警告を取り除くことができますか?

4

1 に答える 1

2

したがって、これら2つは、測定とレイアウトに関する限り、実際にはまったく異なることを行っています。1つ目は、画像に必要なスペースを把握し、そこに配置し、テキストに必要なスペースを把握して、画像の下に配置することです。

2つ目は、テキストに必要なスペースを把握することです。次に、背景の上部に画像を描画し、テキストで使用されるスペース全体に合わせて拡大縮小します。次に、その上にテキストを描画します。

画像を引き伸ばさないようにしたい場合は、最初のバージョンを使用してください。2番目のバージョンはちょうど間違っています。複合ドローアブルは、単一の背景画像がパーツに分割される9つのパッチなどに使用されます。

これらのどちらもあなたが本当に望んでいることをしていない場合は、それが何であるかを説明してください。そうすれば、それを行う方法を理解できるかどうかを確認します。

于 2013-01-20T04:36:26.163 に答える