开发者

View disappear while using relativelayout's "toLeftof"

I'm using Android's relativelayout, trying to make two buttons align side by side. But, when I use layout_toLeftOf, my button02 suddenly disappear. It's fine if I use layout_toRightof. Anyone knows why?

<Button 
    android:id="@+id/Button01" 
    android:layout_alignParentLeft="true" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:text="@+id/Button01">
</Button>

<Button 
    android:id="@+id/Button02" 
    android:layout_height=开发者_StackOverflow社区"wrap_content" 
    android:layout_width="wrap_content" 
    android:text="@+id/Button02" 
    android:layout_toLeftOf="@+id/Button01"
    android:layout_alignTop="@+id/Button01" 
    android:layout_alignBottom="@+id/Button01" 
    >
</Button>


That's because the first one is aligned to the left; if you put the second button to the left of the first one, it will be outside the screen.

So, what if you change

android:layout_alignParentLeft="true"

to

android:layout_alignParentRight="true"

in the first button?


If you want Button2 to be left of Button1, why are you placing alignTop and alignBottom properties? Please remove that and see. Also remove alignParentLeft for Button1, if you want Button1 to be placed at the right side.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜