简体   繁体   English

如何在更多按钮前面显示TextView?

[英]How to display TextView in front of more Buttons?

I have 4 Buttons and 1 TextView with dimensions 240x200 and i want this textview to display over all 4 buttons. 4个按钮和1个尺寸为240x200的TextView,我希望此textview显示在所有4个按钮上。 I tried placing in xml code Text View after buttons and i tried with FrameLayout but it doesn't work in both cases still buttons are over TextView. 我尝试在按钮后放置xml代码文本视图,并尝试使用FrameLayout,但在两种情况下仍然无法使用,但按钮仍然位于TextView上。

xml XML

<?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"
    tools:context="com.example.user.probalayout.MainActivity">


    <Button
        android:id="@+id/button9"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="23dp"
        android:text="Button"
        android:layout_alignTop="@+id/textView"
        android:layout_alignLeft="@+id/textView"
        android:layout_alignStart="@+id/textView" />

    <Button
        android:id="@+id/button10"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignEnd="@+id/textView"
        android:layout_alignRight="@+id/textView"
        android:layout_alignTop="@+id/button9"
        android:text="Button" />

    <Button
        android:id="@+id/button11"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button"
        android:layout_alignBottom="@+id/textView"
        android:layout_alignLeft="@+id/textView"
        android:layout_alignStart="@+id/textView"
        android:layout_marginBottom="37dp" />

    <Button
        android:id="@+id/button12"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/button10"
        android:layout_alignStart="@+id/button10"
        android:layout_alignTop="@+id/button11"
        android:text="Button" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="220dp"
        android:layout_height="200dp"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_marginEnd="70dp"
        android:layout_marginRight="70dp"
        android:layout_marginTop="129dp"
        android:background="#906090"
        android:gravity="center"
        android:text="TextView"
        android:textSize="24sp" />

</RelativeLayout>

尝试使用线性布局,并使用android:orientation属性指定布局方向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM