Android 按钮自动命令到前面
Android Button orders to front automatically
我身上发生了一些奇怪的事情。我有这样的布局:
<?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">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray_dark" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:drawableTop="@drawable/some_drawable"
android:text="Some text" />
</RelativeLayout>
而且我希望 TextView 在按钮上方可见。但由于某种原因,按钮自动转到前面,覆盖了文本视图。当我将 Button 更改为普通 View 时,顺序是正确的。
关于 Android 中的按钮,我是否遗漏了什么?
谢谢
编辑:
预览:
我刚试过同样的事情,奇怪的是,它也发生在我身上。我是这样修的
<?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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF0000"
android:text="lalala"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#FFFF00"
android:text="lalala"/>
</RelativeLayout>
我身上发生了一些奇怪的事情。我有这样的布局:
<?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">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray_dark" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:drawableTop="@drawable/some_drawable"
android:text="Some text" />
</RelativeLayout>
而且我希望 TextView 在按钮上方可见。但由于某种原因,按钮自动转到前面,覆盖了文本视图。当我将 Button 更改为普通 View 时,顺序是正确的。
关于 Android 中的按钮,我是否遗漏了什么? 谢谢
编辑:
预览:
我刚试过同样的事情,奇怪的是,它也发生在我身上。我是这样修的
<?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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF0000"
android:text="lalala"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#FFFF00"
android:text="lalala"/>
</RelativeLayout>