use*_*640 1 android tablerow relativelayout android-layout
在这里,我开发了一个应用程序 在这里,我希望需要以下格式的o/p:
Artist: artist
Duration: duration
Title: title.
Run Code Online (Sandbox Code Playgroud)
但我得到的o/p是:
Artist:
artist
Durstion:
duration
Title:
title
Run Code Online (Sandbox Code Playgroud)
在这里,我希望需要以上格式.
我怎样才能做到这一点?
这里我使用下面的代码作为我的布局文件.但我无法得到我的要求输出.所以请帮助我并给我一些想法.请帮我
这是我的布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/orderinformation"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/payment_method1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5px"
android:text="Artist"
android:textSize="15dip"
android:textStyle="bold" />
<TextView
android:id="@+id/artist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/payment_method1"
android:paddingLeft="75px"
android:text="artist"
android:textColor="#10bcc9"
android:textSize="15dip"
android:textStyle="bold" />
<TextView
android:id="@+id/total1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5px"
android:text="Duration"
android:layout_below="@id/payment_method1"
android:textSize="15dip"
android:textStyle="bold" />
<TextView
android:id="@+id/duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="65px"
android:layout_toRightOf="@+id/total1"
android:text="duration"
android:textColor="#10bcc9"
android:textSize="15dip"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@id/orderinformation" >
<TextView
android:id="@+id/firstname1"
android:paddingLeft="5px"
android:textSize="15dip"
android:layout_below="@id/total1"
android:text="Title"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/title"
android:text="title"
android:paddingLeft="65px"
android:layout_toRightOf="@+id/firstname1"
android:textSize="15dip"
android:textColor="#10bcc9"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
当您使用方向为垂直的LinearLayout时,您将获得前一个布局下方的每个新布局.更好的是使用RelativeLayout.作为android:layout_toRightOfRelativeLayout的属性,它在LinearLayout中没有任何效果.
在你的情况下最好的是使用TableLayout,只需要将TextView放在TableRow中.
伪代码,
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TableRow>
<TextView
android:id="@+id/payment_method1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dip"
android:text="Artist"
android:textSize="15dip"
android:textStyle="bold" />
<TextView
android:id="@+id/artist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dip"
android:text="artist"
android:textColor="#10bcc9"
android:textSize="15dip"
android:textStyle="bold" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/total1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dip"
android:text="Duration"
android:textSize="15dip"
android:textStyle="bold" />
<TextView
android:id="@+id/duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dip"
android:text="duration"
android:textColor="#10bcc9"
android:textSize="15dip"
android:textStyle="bold" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/firstname1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dip"
android:text="Title"
android:textSize="15dip"
android:textStyle="bold" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dip"
android:text="title"
android:textColor="#10bcc9"
android:textSize="15dip"
android:textStyle="bold" />
</TableRow>
</TableLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10436 次 |
| 最近记录: |