2012-03-28 10 views
1

ほとんどの.xmlファイルで、サイズが画面によって大きくなったり、画面の一部が大きくなったりするという問題がありました。私はpx(ピクセル)を使用します。Androidの.xmlデザイン

これは私の目的では悪い選択かもしれないが、新しい携帯電話はより多くのピクセル比率で終了するだろうということを知っている。サムスンギャラクシーネクサスはすべてのテキストを小さなテキストにします。

今後の携帯電話には、はるかに適したタイプは何でしょうか?

エクストラ:

私は長い間、リニアレイアウトを使用してきたが、今私は長いメニューのスクロールが必要であることを私はScrollViewは線形レイアウトをネストScrollViewを入れ子にRelativeLayoutを設計しました。ビューをより詳細に制御できるようにtableLayoutをネストする方が良いでしょうか?

質問画面が洪水になりたくないと思われました。

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

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

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

      <TextView 
       android:id="@+id/tab_tv_one" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_above="@+id/auto_Action" 
       android:background="#666666" 
       android:text="@string/options_dialog_menu_Action" 
       android:textSize="27px" 
       /> 

      <RadioGroup 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical"> 

      <RadioButton 
       android:id="@+id/FirstOption" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_above="@+id/manual_Action" 
       android:layout_below="@+id/tab_tv_one" 
       android:text="@string/options_dialog_menu_Auto_Action" 

       android:textSize="27px" /> 

      <RadioButton 
       android:id="@+id/SecondOption" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_above="@+id/tab_tv_two" 
       android:layout_below="@+id/auto_Action" 
       android:text="@string/options_dialog_menu_Manual_Action" 
       android:textSize="27px" 
       android:onClick="onClick" 
       android:clickable="true" 

       /> 

      <RadioButton 
       android:id="@+id/ThirdOption" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_above="@+id/tab_tv_two" 
       android:layout_below="@+id/manual_Action" 
       android:textSize="27px" 
       android:onClick="onClick" 
       android:clickable="true" 

       /> 

      </RadioGroup> 



      <TextView 
       android:id="@+id/tab_tv_two" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_above="@+id/text_size" 
       android:layout_below="@+id/manual_Action" 
       android:background="#666666" 
       android:text="@string/options_dialog_menu_Layout_Options" 
       android:textSize="27px" 
       /> 

      <TextView 
       android:id="@+id/text_size" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_above="@+id/background_clr" 
       android:layout_below="@+id/tab_tv_two" 
       android:text="@string/options_dialog_menu_Text_Size" 
       android:textSize="27px" 
       android:onClick="onClick" 
       android:clickable="true" 

       /> 

      <TextView 
       android:id="@+id/Options_clr" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_above="@+id/brightness_ctrl" 
       android:layout_below="@+id/text_size" 
       android:text="@string/options_dialog_menu_Color_Options" 
       android:textSize="27px" 
       android:onClick="onClick" 
       android:clickable="true" 

       /> 

      <TextView 
       android:id="@+id/brightness_ctrl" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/background_clr" 
       android:text="@string/options_dialog_menu_Brightness_color" 
       android:textSize="27px" 
       android:onClick="onClick" 
       android:clickable="true" 

       /> 
      <TextView 
       android:id="@+id/backToBasics" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/brightness_ctrl" 
       android:text="@string/options_dialog_menu_Back_To_Basics" 
       android:textSize="27px" 

       android:onClick="onClick" 
       android:clickable="true" 
       /> 


    </LinearLayout> 
    </ScrollView> 
</RelativeLayout> 
+1

私はピクセルの代わりにdpを使う必要があると思います。 – kosa

答えて

1

ピクセルを使用しないでください.dp(aka dip aka density independent pixels)を使用してください。そうでなければ、あなたが指摘したように、サイズは密度に依存しますが、それは良くありません。

ldpiの携帯電話はmdpiとは異なり、hdpiとは違って見えます。特に、ビューの大きさに関しては、pxサイズを使用する正当な理由はまれです。

あなたの余分な質問に関しては、あなたのレイアウトがどのように見えるかによってまったく異なります。コードを見たり、少なくともあなたが何を起こそうとしているかを知ることなく(あなたが今見ているものに対して)、誰もそれに本当に答えることはできません。

+0

コードを追加します。質問画面をあまりにも氾濫させたくありませんでした。 – sdfwer

+0

それで、ピクセルをdpに変更するのではなく(それは痛みになりますが、それには完全に価値があります)、あなたは何か不合理なことをしていません。あなたがそれを望むように見えるようにレイアウトを得るのが難しいのでなければ、それをそのままにしておいてください。あなたがテーブルレイアウトの機能を必要としているのを見たら、それを使わない理由は何もなく、実際に必要なときにいつでも後で切り替えることができます。 –

関連する問題