0

2x2グリッドに4つのImageButtonがある画面があります(TableLayoutを使用)。

さまざまな画面サイズすべてをサポートする必要があります。そこで、4つのレイアウトフォルダー(小、中、大、特大)を作成しました。

ImageButtonの位置は問題なく機能しました。ただし、大画面と特大画面では、ImageButtonのサイズが小さすぎます。

mdpiと他のフォルダー間のx0.75、x1、x1.5、およびx2の関係を使用して、異なる密度の4つのフォルダー(drawable-ldpi、drawable-mdpi、drawable-hdpi、およびdrawable-xhdpi)を使用してこの問題を解決しようとしました。

しかし、それが機能していないか、これを解決する正しい方法ではないと思います。

それは解決する正しい方法ですか?

画面が小さいのが気になりますが、高密度です。または低密度の中画面。そのような場合、おそらく機能していませんよね?

私が持っている他のアイデアは、すべてのサイズのフォルダーのすべてのレイアウトにImageButtonのサイズ(ディップで測定)を強制することです。それを解決するためのより良い方法ですか?

私はこれで本当に負けました。最良/正しい解決策を適用したい。

誰かが私を助けることができますか?

私の貧弱な英語に感謝し、申し訳ありません

アップデート:

レイアウトは次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:gravity="center_horizontal">

    <TableRow
        android:gravity="center"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:layout_marginTop="60dip"  >

        <ImageButton
            android:id="@+id/newCard_button"
            android:layout_margin="10dip"    
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"             
            android:background="@drawable/selector_new_card_button"/>

        <ImageButton
            android:id="@+id/showLastTicket_button"
            android:layout_margin="10dip"      
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"          
            android:background="@drawable/selector_show_last_ticket_button"/>

    </TableRow>

    <TableRow
        android:gravity="center"        
        android:layout_height="fill_parent"
        android:layout_width="fill_parent">

         <ImageButton
            android:id="@+id/cancelLastTransaction_button"
            android:layout_margin="10dip"      
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"           
            android:background="@drawable/selector_anulla_button"/>

        <ImageButton
            android:id="@+id/searchCustomer_button"
            android:layout_margin="10dip"      
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" 
            android:background="@drawable/selector_search_customer_button"/>

    </TableRow>
</TableLayout>
4

2 に答える 2

1

さて、これについて私が提案するのは、比較的新しい修飾子sw600dpsw720dp(最短幅:600dpまたは720dp)を使用して、これらの画面のより大きなサイズを定義することです。これらは基本的に7インチと10インチのタブレットです。変更する必要のある量に応じて、特定のdimen変数を定義してリソースフォルダーに大きな値を設定するvalues-sw600dpか、実際にリソースフォルダーにまったく異なるレイアウトを作成することができますlayout-sw600dp

于 2012-08-09T19:00:16.563 に答える
0

コンテンツを折り返す代わりに50dipのような正確な値を指定することで、レイアウト内のImageButtonの幅と高さの値を調整することができます。ディップは密度に依存しないピクセルを意味するため、ディップ値はさまざまな画面にさまざまなサイズで表示されます。

于 2012-08-09T19:51:05.827 に答える