0

私のアプリケーションはハンドセットでは正常に動作しますが、TAB UI で実行すると小さすぎます。しかし、UI のサイズをデバイスのサイズに合わせたいと考えています。マニフェストに何かを追加する必要がありますか.何が間違っているのですか.Here is My XML

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" 
android:orientation="vertical">

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Select The Game Level" />

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Level1" />

<Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="level2" />

<Button
    android:id="@+id/button3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="level3" />
 </LinearLayout>
Handset UI appearence

ハンドセット UI の外観

Tablet UI appearence

タブレット UI の外観

4

1 に答える 1

1

ここであなたの推測を試してみましょう:

  1. ボタンのサイズは「wrap_content」に設定されています。ラップするテキストのサイズに依存することを意味します。

  2. アプリを表示している画面の視覚的なサイズに応じて、ボタンの視覚的なサイズを変更する必要があります。

  3. Therfore: 基本的に、デバイスの画面に応じてフォント サイズが変わることを期待しています。

これがあなたが望むものを達成するための正しいアプローチだとは思いません。ここで役立つツールがいくつかあります。そのうちの 1 つを調べてみましょう: weight 属性: android:layout_weight とはどういう意味ですか?

これは、どの画面でも視覚的に似ているボタンの配列の例です(ここでは「類似」を強調していますが、これがあなたが達成しようとしているものです):

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

        <Button
            android:id="@+id/btnMainMenuTestUSB"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button1" />

        <Button
            android:id="@+id/btnMainMenuSetLocationNew"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button2" />
    </LinearLayout>

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

        <Button
            android:id="@+id/btnLineOfSight"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button3" />

               <Button
            android:id="@+id/btnTargetScreen"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button4" />
    </LinearLayout>
于 2013-08-26T08:34:54.917 に答える