【发布时间】:2016-04-10 17:10:18
【问题描述】:
我希望我的按钮看起来与this 完全一样,但我不知道该怎么做。我曾尝试在谷歌上查看不同的地方,但没有一种方式像我想要的那样。我想让我的按钮有图像,我也想知道如何在不同的屏幕尺寸上调整这些图像的大小。
这是我现在的 layout_main.xml。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.mudd.devin.drivenow.MainActivity"
android:weightSum="2">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button3"
android:layout_marginTop="199dp">
</Button>
<Button
android:layout_width="wrap_content"
android:id="@+id/button1"
android:layout_gravity="center"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_vertical_margin" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button2"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
【问题讨论】:
-
使用具有相等
android:layout_weight值的嵌套LinearLayout小部件。或者,使用 Android 支持包中的PercentFrameLayout/PercentRelativeLayout。