【发布时间】:2016-02-27 11:56:27
【问题描述】:
我有以下布局(这里展示了更简单的设计):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/activity_main">
<FrameLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hey, badge!"
android:layout_margin="10dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AAAAA"
android:layout_margin="10dp"
android:textSize="12sp"
android:background="#ff00ff"
android:padding="10dp"
android:layout_gravity="top|end"
/>
</FrameLayout>
</RelativeLayout>
我希望用文本“AAAA”设置 TextView 作为 Button 的标记,即放置在右上角的按钮上,但事实并非如此。
相反,当我在带有 Lollipop 的 HTC One M7 或带有 Lollipop 的 Genymotion Nexus 6 上尝试此代码时,屏幕看起来像这样:
当我使用 KitKat 在 Genymotion Nexus 5 上尝试相同的代码时,一切看起来都符合预期,即 第一个视图(按钮)显示在徽章(文本视图)下方
有人知道这里有什么问题吗?
谢谢, 德维蒂
【问题讨论】:
标签: android android-layout android-framelayout