tha*_*you 7 xml layout android android-layout
我有三个TextViews.第一个和第三个定义为不更改文本.第二个,第一个和第三个之间的TextView通过输入获取值.如何在布局中的第一个和第三个之间设置第二个TextView?
<TextView
android:id="@+id/secondtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/firsttext"
android:layout_above="@+id/thirdtext"
android:layout_alignLeft="@+id/firsttext"
android:layout_alignRight="@+id/thirdtext"
android:background="@drawable/border"
android:scrollbars="vertical"
android:textAppearance="?android:attr/textAppearanceMedium" />
Run Code Online (Sandbox Code Playgroud)
那不行!
<TextView
android:id="@+id/secondtext"
android:layout_width="282dp"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/firsttext"
android:layout_below="@+id/firsttext"
android:background="@drawable/border"
android:ellipsize="marquee"
android:lines="4"
android:scrollbars="vertical"
android:textAppearance="?android:attr/textAppearanceMedium" />
Run Code Online (Sandbox Code Playgroud)
这也行不通
依赖性过多,请检查xml中是否遇到任何循环依赖性错误。根据您的要求,在不指定间距和其他UI详细信息的情况下,一种解决方案:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/black" >
<TextView
android:id="@+id/firsttext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:text="first"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/secondtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/firsttext"
android:background="@android:color/white"
android:text="second"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/thirdtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/secondtext"
android:background="@android:color/white"
android:text="third"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
54275 次 |
| 最近记录: |