我是新来的android开发,我想让我的按钮覆盖页面的整个宽度,没有任何一方的空间。我研究了这一点,并使用Android的重量不起作用。如何使用相对布局使按钮填充屏幕(宽度)?
这里是XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
style="@style/AppTheme"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"
android:icon="@drawable/ic_launcher"
android:scrollbars="horizontal|vertical"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="98dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="@drawable/buttonpress"
android:text="@string/hello_world"
android:textColor="#228496"
android:textSize="14sp" />
<Button
android:id="@+id/categories"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="14dp"
android:background="@drawable/buttonpress"
android:onClick="Categories"
android:text="@string/title_activity_categories"
android:textColor="#228496"
android:textSize="21sp" />
<Button
android:id="@+id/feedback"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignLeft="@+id/categories"
android:layout_below="@+id/categories"
android:layout_marginTop="15dp"
android:background="@drawable/buttonpress"
android:onClick="feedback"
android:text="@string/Feedback"
android:textColor="#228496"
android:textSize="21sp" />
</RelativeLayout>
您的布局看起来是正确的。根据您的主题/样式,您可能在按钮上有一些默认边距。尝试在android:layout_marginTop =“14dp”下添加android:layout_margin =“0dp”。此外,你的按钮可绘制,如果它是一个图像,可能在你需要挖掘的PNG空白。 – 2013-05-03 19:38:09
还有一些边框...我已经实现了所有这些方法... – user2229066 2013-05-03 21:18:59
你可以发布截图吗? – 2013-05-03 21:24:31