Swe*_*per 5 xml android android-layout android-view
我有一个TextView(下面用绿色表示)和一个LinearLayout(下面用红色表示)RelativeLayout。我想将 TextView 放在 之上LinearLayout,如下所示:

但是,我试过这个:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/linear_layout">
<!--some other views-->
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" <!--this because the textview is the topmost view on the screen so I tried to use this-->
android:layout_alignLeft="@id/linear_layout"
android:text="my text"
android:textSize="10pt"
android:id="@+id/text1"/>
Run Code Online (Sandbox Code Playgroud)
但是,当我运行该应用程序时,它是这样的:
所以我想知道我做错了什么以及如何解决它。是否有我可以使用的 xml 属性?
如果您需要更多代码来识别问题,请随时告诉我!
把你的LinearLayout后TextView像这样:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" <!-- this because the textview is the topmost view on the screen so I tried to use this -->
android:text="my text"
android:textSize="10pt"
android:id="@+id/text1" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text1"
android:orientation="vertical"
android:id="@+id/linear_layout">
<!-- some other views -->
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14966 次 |
| 最近记录: |