<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:gravity="center"> <Button android:id="@+id/t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用户名"/> <Button android:id="@+id/textname2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2222"
android:layout_toLeftOf="@id/t1" />
</RelativeLayout>
请问代码有什么问题吗 为什么效果出不来呢 效果应该是“222”在“用户名”的左边啊
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:gravity="center"> <Button android:id="@+id/t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用户名"/> <Button android:id="@+id/textname2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2222"
android:layout_toLeftOf="@id/t1" />
</RelativeLayout>
请问代码有什么问题吗 为什么效果出不来呢 效果应该是“222”在“用户名”的左边啊
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:gravity="center"><Button android:id="@+id/t1"
android:layout_toRightOf="@id/textname2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用户名"/><Button android:id="@+id/textname2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2222"
/></RelativeLayout>或者在222上加上靠左相对于整个RelativeLayout属性
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:gravity="center"
android:orientation="horizontal"> <Button android:id="@+id/textname2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2222"
android:layout_toLeftOf="@id/t1" />
<Button android:id="@+id/t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用户名"/></LinearLayout>
这样写 试过 都能显示