I've got some problem with positioning TextViews
. Currently my layout looks like:
Text1: Text2
Text3: Text4
Ok, but when Text2
has 2 rows length or more I've got:
Text1: Text2:1
Text3: Text2:2/Text4
I don't know how to set up my layout to obtain view like:
Text1: Text2:1
Text2:2
Text3: Text4
Can somebody help me solve that problem?
XML code:
(...)
//Text1:
<TextView
android:id="@+id/tv_author_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_genre_label"
android:layout_toRightOf="@+id/img_Cover"
android:text="Author: "
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
//Text2:
<TextView
android:id="@+id/tv_author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/tv_author_label"
android:layout_alignBottom="@+id/tv_author_label"
android:layout_toRightOf="@+id/tv_author_label"
android:text="Anonymous Anonymous"
android:textAppearance="?android:attr/textAppearanceMedium" />
//Text3:
<TextView
android:id="@+id/tv_availability_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_author_label"
android:layout_toRightOf="@+id/img_Cover"
android:
android:textStyle="bold"
android:text="Availability: "
android:textAppearance="?android:attr/textAppearanceMedium" />
//Text4:
<TextView
android:id="@+id/tv_availability"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/tv_availability_label"
android:layout_alignBottom="@+id/tv_availability_label"
android:layout_toRightOf="@+id/tv_availability_label"
android:layout_alignParentLeft="@+id/tv_availability_label"
android:layout_below="@+id/tv_author"
android:text="b/d"
android:textAppearance="?android:attr/textAppearanceMedium" />
(...)
you can reconstruct your code something like this,
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<TextView
android:id="@+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dfsdjfkd dsfsdf sdfsdf sdfsdfsd fjlsdjf sdj; j; jlksdfjl sdjflkdsjflsdk jkldsjf lsjldkfj sdl" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/tv3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<TextView
android:id="@+id/tv4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</LinearLayout>
I hope it will be helpful !!
您可以将文本视图的行封装在具有方向的线性布局内-Horiontal
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.