2

これは非常に基本的な質問のように思えますが、理解できないようです。Androidを大小の画面にスケーラブルにする方法について、かなりの量の読書をしました。

タブレット用に設計されたアプリがあり、そこでうまく機能します。ただし、モバイル (電話) バージョンに取り組んでいる間、誰かが電話で開いた場合に少なくとも「OK」に見えるようにしたいと考えています。

ボタン以外の誰もがう​​まくスケーリングします....ボタンをスケーリングすることができないようです。

タブでは見栄えがしますが、電話では画面全体を占めます。

お手伝いありがとう。

コードは次のとおりです。

Main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/main_landscape"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/main_menu_plus_landscape"
    android:orientation="vertical" >

    <Button
        android:id="@+id/button_list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_marginRight="38dp"
        android:layout_marginTop="200dp"
        android:background="@layout/button_main_selector"
        android:padding="40dp"
        android:text="@string/main_start_list"
        android:textColor="@color/white"
        android:textSize="30dp"
        android:typeface="sans"/>


    <Button
        android:id="@+id/button_emulator"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/adview"
        android:layout_alignLeft="@+id/button_list"
        android:layout_alignRight="@+id/button_list"
        android:layout_marginBottom="168dp"
        android:background="@layout/button_main_selector"
        android:padding="40dp"
        android:text="@string/main_start_emulator"
        android:textColor="@color/white"
        android:textSize="30dp"
        android:typeface="sans" />

</RelativeLayout>

レイアウト/button_main_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Button Focused-->
    <item   android:state_focused="true"
            android:state_pressed="false"
            android:drawable="@drawable/main_buttons_selected"
            />
<!-- Button Focused Pressed-->
    <item   android:state_focused="true"
            android:state_pressed="true"
             android:drawable="@drawable/main_buttons_selected"
            />
<!-- Button Pressed-->
    <item   android:state_focused="false"
            android:state_pressed="true"
            android:drawable="@drawable/main_buttons_selected"
            />
<!-- Button Default Image-->
    <item   android:drawable="@drawable/main_buttons"/>

</selector>

drawable-hdpi/main_buttons.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
 <solid android:color="#71bbe3"/> 
    <corners
     android:bottomRightRadius="10dp"
     android:bottomLeftRadius="10dp"
      android:topLeftRadius="10dp"
      android:topRightRadius="10dp"/>
</shape>

また、ボタンファイルを「描画可能」に配置しようとしましたが、役に立たないようです。助言がありますか?(注:私のボタンは単色で、画像はありません)

res/drawable/main_buttons.xml

res/drawable/main_buttons_selected.xml

res/drawable/button_main_selector.xml
4

4 に答える 4

0

私はあなたのコードを見ました、最初に私はあなたに話します、あなたはあなたがどんな種類の見方をしたいのかという画像を投稿するべきです、2番目の泥棒はあなたが与えたものです

android:layout_marginRight="38dp"

android:layout_marginTop="200dp"

最初のボタンコードと2番目のボタンでuはこのようなマージンを与えています

android:layout_marginBottom="168dp"

そして、他のすべてのものは、どのようなデザインを実装したいかというレイアウトに依存します。

あなたへの私の提案は、特に左から右の方向にマージンを与えることは決してありません。たとえば、左から50ピクセルにマージンを与えると、通常のデバイスでは問題ないように見えますが、高解像度のデバイスでは見栄えがよくないため、どの解像度でも50ピクセルかかるためです。 device。マージンの代わりに、この種の構文android:alignParentLeft = trueを使用し、相対レイアウト内でこの種の構文を使用する習慣が常にあります。このような構文を使用すると、要素は常に目的の位置に配置されます。.goto android開発者サイトで、線形レイアウトと相対レイアウトの違いと、線形レイアウトと相対レイアウトの異なるプロパティを確認して、の意味などのすべてのプロパティを調べてください。100%を超えるとfill_parent、解決策が得られます。ここで私wrap_contentmatch_parenthttps://chat.stackoverflow.com/rooms/13436/smart-phones-developerここであなたの問題を私に尋ねることができます。そして私はあなたにあなたの画像を投稿することを提案します

アーミルカーンIに感謝します。

于 2012-10-15T05:21:05.680 に答える
0

あなたが提供した情報から、私は問題を次のように予測しています。そのため、電話でアプリを実行すると、ボタンが hdpi から取得され、電話の外観が奇妙になります。これは、drawable または ldpi でボタンを指定するだけで解決できます。電話の画面にフィットします。これが問題かもしれません。

于 2012-10-15T05:08:12.317 に答える
0

両方のxmlを入れるだけですdrawable

drawableプロジェクトの resという名前のフォルダーを作成することにより

res/drawable/main_buttons.xml

res/drawable/button_main_selector.xml
于 2012-10-15T05:10:59.470 に答える