我有4 个按钮和 1 个文本视图,尺寸为 240x200,我希望这个文本视图显示在所有 4 个按钮上。我尝试在按钮之后放置 xml 代码文本视图,我尝试使用 FrameLayout 但它在两种情况下都不起作用仍然按钮在 TextView 上。
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 属性指定布局方向。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句