2016-08-13 1 views
0

どのようにボタンを配置し、下の図のようなすべてのデバイスで作業できますか?ボタンを配置してアンドロイドスタジオのすべてのデバイスでどのように作業できますか?

黄色のボタンは他の色と同様にデザインされています。

私はRelativeLayoutを試してみたが、別のデバイス に同じ構成を仕事とのLinearLayoutを試みるが、同じ配置で付属していませんしません。アンドロイドStudioで

enter image description here

<LinearLayout 
      android:orientation="vertical" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:gravity="center_horizontal"> 

      <Button 
       style="?android:attr/buttonStyleSmall" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/button34" 
       android:layout_weight="1" 
       android:background="@drawable/out_up" /> 

      <Button 
       style="?android:attr/buttonStyleSmall" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/button33" 
       android:layout_weight="1" 
       android:background="@drawable/green" /> 

      <Button 
       style="?android:attr/buttonStyleSmall" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/button36" 
       android:layout_weight="1" 
       android:background="@drawable/yellow" /> 

      <Button 
       style="?android:attr/buttonStyleSmall" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/button37" 
       android:layout_weight="1" 
       android:background="@drawable/yellow" /> 

      <Button 
       style="?android:attr/buttonStyleSmall" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/button38" 
       android:layout_weight="1" 
       android:background="@drawable/yellow" /> 

      <Button 
       style="?android:attr/buttonStyleSmall" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/button39" 
       android:layout_weight="1" 
       android:background="@drawable/yellow" /> 

      <Button 
       style="?android:attr/buttonStyleSmall" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/button40" 
       android:layout_weight="1" 
       android:background="@drawable/yellow" /> 

      <Button 
       style="?android:attr/buttonStyleSmall" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/button35" 
       android:layout_weight="1" 
       android:background="@drawable/green_down" /> 
     </LinearLayout> 

    </LinearLayout> 
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:gravity="center_horizontal"> 

     <Button 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/button43" 
      android:layout_weight="1" 
      android:background="@drawable/green_out_up" /> 

     <Button 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/button44" 
      android:layout_weight="1" 
      android:background="@drawable/yellow" /> 

     <Button 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/button42" 
      android:layout_weight="1" 
      android:background="@drawable/yellow" /> 

     <Button 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/button45" 
      android:layout_weight="1" 
      android:background="@drawable/yellow" /> 

     <Button 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/button47" 
      android:layout_weight="1" 
      android:background="@drawable/yellow" /> 

     <Button 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/button46" 
      android:layout_weight="1" 
      android:background="@drawable/yellow" /> 

     <Button 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/button41" 
      android:layout_weight="1" 
      android:background="@drawable/green_out_down" /> 
    </LinearLayout> 

    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:gravity="center_horizontal" > 

     <Button 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/button49" 
      android:layout_weight="1" 
      android:background="@drawable/out_up_right" /> 

     <Button 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/button53" 
      android:layout_weight="1" 
      android:background="@drawable/right_red" /> 

     <Button 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/button54" 
      android:layout_weight="1" 
      android:background="@drawable/right_red" /> 

     <Button 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/button55" 
      android:layout_weight="1" 
      android:background="@drawable/right_red" /> 

     <Button 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/button56" 
      android:layout_weight="1" 
      android:background="@drawable/right_red" /> 

     <Button 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/button57" 
      android:layout_weight="1" 
      android:background="@drawable/right_red" /> 

     <Button 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/button52" 
      android:layout_weight="1" 
      android:background="@drawable/right_red" /> 

     <Button 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/button48" 
      android:layout_weight="1" 
      android:background="@drawable/out_down_right" /> 
    </LinearLayout> 


</LinearLayout> 
<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:gravity="center_horizontal"> 

    <Button 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/button51" /> 
</LinearLayout> 

このような結果:

enter image description here

+0

すべてのアンドロイドのレイアウトは長方形なので、このレイアウトをどのように構築していますか?ドロワーブルの使用? –

+0

画像ボタンやボタン、背景を使って、すべての形をPhotoshopで作っています。仕事はしていますが、同じ配置ではありません –

+0

XMLレイアウトを[編集]と共有できますか? –

答えて

0

あなたの歪みをしたくない場合は、「安全なエリアを定義する必要がありますレイアウト固定アスペクト比である「ボード領域」または「ボード領域」である。

この「安全領域」には、幅や高さに浮動パッドを埋め込む必要があります。例えば

------------------------------------------ 
| pad =============================== pad | 
| + + ======  safe area  ====== + + | 
| pad =============================== pad | 
| + + ======  safe area  ====== + + | 
| pad =============================== pad | 
| + + ======  safe area  ====== + + | 
| pad =============================== pad | 
| + + ======  safe area  ====== + + | 
| pad =============================== pad | 
------------------------------------------ 

または同じ幅ではない画面の両方の例で

----------------------------------- 
| + pad + + pad + + pad + + pad + | 
| =============================== | 
| ======  safe area  ====== | 
| =============================== | 
| ======  safe area  ====== | 
| =============================== | 
| ======  safe area  ====== | 
| =============================== | 
| ======  safe area  ====== | 
| =============================== | 
| + pad + + pad + + pad + + pad + | 
----------------------------------- 

ための「安全領域」とは、同じ大きさであり、唯一のパディングが変更されました。

+0

安全領域の意味 –

+0

「安全領域」は、歪みのないすべての画面サイズで使用したい画面のセクションです。これは画面の幅と高さに関係なく常に見られる画面のセクションです。 – Tigger

関連する問題