我想设计如下图所示的布局:
我尝试使用相对布局来做到这一点,但我没有想出解决方案。对于所有设备屏幕,它应该处于相同的位置。我怎样才能实现它??? 我试过这段代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/relative_layout_top"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/obaz" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/relative_layout_bottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/relative_layout_top"
android:background="@drawable/obaz2" >
<Button
android:id="@+id/bt_atoz"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="-20dp"
android:background="@drawable/button_active" />
</RelativeLayout>
</RelativeLayout>
任何建议将不胜感激。
最佳答案
您可以将 Button
声明放在 RelativeLayout
relative_layout_bottom 之外
然后把它放在你喜欢的地方。
例如: 编辑:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/relative_layout_top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/obaz" >
</RelativeLayout>
<Button
android:id="@+id/bt_atoz"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@drawable/button_active" />
<RelativeLayout
android:id="@+id/relative_layout_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/relative_layout_top"
android:background="@drawable/obaz2" >
</RelativeLayout>
</RelativeLayout>
关于android - 如何在 android 中的一个布局上显示一半按钮,在另一个布局上显示一半按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17091362/