【发布时间】:2018-04-06 12:58:29
【问题描述】:
在我的布局中,我有一个带有两个 RadioButtons 的 RadioGroup。我在 RadioGroup 上放了一个 TextView。
但 TextView 没有显示在 RadioGroup 上方。只有水平的单选按钮是可见的。布局代码如下:-
<android.support.design.widget.CoordinatorLayout
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:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbarstart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioGroup
android:layout_marginTop="60dp"
android:id="@+id/radiogroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/east"
android:textSize="18sp"/>
<RadioButton
android:id="@+id/radioButton2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/west"
android:textSize="18sp"/>
</RadioGroup>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/radiogroup"
android:layout_centerHorizontal="true"
android:layout_marginBottom="25dp"
android:text="Vehicle Direction"
/>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
请指导解决问题。
【问题讨论】:
-
RelativeLayout是和appbarlayout重叠的问题,使用线性布局或者框架布局会显示textview