0

レイアウトの例を次に示します。

<RelativeLayout 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"
    tools:context=".MainActivity" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="50dp"
        android:text="@string/hello_world" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="50dp"
        android:src="@drawable/ic_launcher" />

</RelativeLayout>

受話器(480x800)とタブレット(1280x800)では、レイアウトの残りのスペースは、イメージビューから下部まで異なります。画像はタブレット上で拡大縮小されておらず、dp値は比較的同じ物理値になります。

画像、スペース(dp)が拡大縮小されるように、タブレットの受話器の比率を保存する方法/ツールはありますか?おそらく、values-xlarge / dimen.xml、values-720dp / dimen.xmlを使用できますが、それは多くの機械的な仕事です。より良い解決策はありますか?

4

3 に答える 3

0

これを試して:

<LinearLayout 
      :
      :        
 android:focusable="true"
      :
/>
于 2013-02-19T09:54:52.553 に答える
0

2 倍の大きさのディスプレイでアプリを 2 倍の大きさ (すべての寸法とフォント サイズ x2) にしたい場合は、表示密度を手動で変更できます (半分に減らします)。Android は問題なく、通常どおり動作します。アプリを同じにして、画面サイズに応じてスケールのみを変更する場合に、このトリックを使用します。Configuration / DisplayMetrics / updateConfigurationについて読んでください。アクティビティの onCreate で実行する必要があるドラフト コードを次に示します。後で正確なコードを示します。

DisplayMetrics dm = context.getResources().getDisplayMetrics();
// fix display density here to scale all activity's dimentions
context.getResources().updateConfiguration(null, dm);

しかし、それは適切なアンドロイドの方法ではありません。適切なリソース フォルダーを使用して、画面サイズごとに異なるリソースを提供する必要があります。

于 2013-02-19T10:04:01.250 に答える
0

ImageView のスケーリングを調整する場合は、追加します

 android:scaleType="fitXY"

ImageView Scale タイプは次のとおりです http://developer.android.com/reference/android/widget/ImageView.ScaleType.html

于 2013-02-19T09:56:16.013 に答える