アプリケーションには、テキストがなく、背景のみが描画可能なボタンがいくつかあります。drawable-?dpi
ドローアブルが適切なフォルダから取得され、サイズ変更せずに表示されるようにする必要があります。最初の部分は機能し、適切な画像ファイルが選択されます。ただし、ボタンの属性layout_height
や属性に関係なく、サイズは変更されます。layout_width
私の質問は、これを打ち負かし、ドローアブルを画面のピクセルごとにマップする方法です。
サイズを変更しないようにする唯一の方法は、で幅と高さを指定するpx
ことです。これは、まさに私がやりたくないことです。そして、私がそれをしたくない理由は、異なる密度に対して描画可能なサイズをdimensions
指定できたファイルが、密度ではなく画面サイズによって区別されるためです。px
私のレイアウトは次のようになります。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="3dp"
android:paddingTop="3dp" >
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn" />
</RelativeLayout>
</LinearLayout>
</ScrollView>