如何安排按钮并在所有设备上工作,如下图所示?如何安排按钮并在android studio中的所有设备上工作?
黄色是一个按钮,其他颜色只是设计。
我尝试RelativeLayout的但在另一个装置 不起作用相同的配置,并尝试的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/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>
Android Studio中的结果是这样的:
所有的android布局是矩形的,所以你如何构建这个布局?使用drawables? –
通过使用图像按钮或按钮和背景以及我通过Photoshop制作的每一个形状。是工作,但没有相同的安排 –
你能分享你的XML布局与[编辑]? –