Here is my layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/outerBox"
android:layout_width="wrap_content"
android:layout_height="fill_parent" >
<GridLayout
android:id="@+id/checksHere"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:columnCount="5"
android:columnWidth="100dp" />
<GridLayout
android:id="@+id/textHere"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/checksHere"
android:columnCount="4" />
<Button
android:id="@+id/submitButton"
android:layout_width="185dip"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/outerBox"
android:layout_below="@id/textHere"
android:layout_margin="3dip"
android:onClick="submit"
android:text="@string/submit" />
<Button
android:id="@+id/cancelButton"
android:layout_width="185dip"
android:layout_height="wrap_content"
android:layout_below="@id/textHere"
android:layout_margin="3dip"
android:layout_toRightOf="@id/submitButton"
android:onClick="next"
android:text="@string/cancel" />
<Button
android:id="@+id/backButton"
android:layout_width="185dip"
android:layout_height="wrap_content"
android:layout_below="@id/textHere"
android:layout_margin="3dip"
android:layout_toRightOf="@id/cancelButton"
android:onClick="next"
android:text="test" />
</RelativeLayout>
I have a relative layout. The layout has two grid layouts at the top, which can be populated in my java code with text or checks. They can be blank. Then I have three buttons. The first two buttons display on the screen just fine. The third button just sits on top of the first button:
I changed the third button (backButton) to be toRightOf submitButton just to see what would happen. It goes on top of the cancelButton, as expected. I feel like I'm missing a simple fundamental, but I have not been able to figure it out.
Well this doesn't necessarily fix the problem with RelativeLayout, but you could always group the three buttons together in a single LinearLayout. This should prevent the buttons from overlapping.
我不确定,但是在eclipse中进行测试时,将所有android:layout_width="185dip"
更改为android:layout_width="wrap_content"
对我来说都是有效的。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.