Android 线性布局不';不行。标题没有出现?
我有一个问题要问你们大家。当我在eclipse中的xml文件中有一个简单文本时。为什么标题没有出现 我搜索过类似的问题,但在stackoverflow上找不到。希望有人能帮助我 不幸的是,我不能发布图片。文本:@string/ondergewicht是文本的标题 @/string/ondergewichttekst是我使用的文本 这就是我用过的代码。对不起,如果这是一个愚蠢的问题,我相信这是Android 线性布局不';不行。标题没有出现?,android,xml,android-layout,layout,android-linearlayout,Android,Xml,Android Layout,Layout,Android Linearlayout,我有一个问题要问你们大家。当我在eclipse中的xml文件中有一个简单文本时。为什么标题没有出现 我搜索过类似的问题,但在stackoverflow上找不到。希望有人能帮助我 不幸的是,我不能发布图片。文本:@string/ondergewicht是文本的标题 @/string/ondergewichttekst是我使用的文本 这就是我用过的代码。对不起,如果这是一个愚蠢的问题,我相信这是 <?xml version="1.0" encoding="utf-8"?> <Lin
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:id="@+id/ondergewichttekst"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textStyle="italic"
android:layout_marginTop="80dp"
android:gravity="center"
android:text="@string/ondergewichttekst"
android:textSize="16sp"/>
<TextView
android:id="@+id/ondergewicht"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textStyle="italic"
android:gravity="center"
android:layout_marginTop="1dp"
android:text="@string/ondergewicht"
android:textSize="30sp"
/>
</LinearLayout>
因此,显示了ondergewichttekst,但没有显示Overgewitcht。也许有类似文本订单的东西
希望有人能帮我
Jacob线性布局中有水平方向,第一个文本视图有
布局\u宽度=匹配\u父视图
这没有意义,第二个文本视图没有更多空间。
使用布局的垂直方向或使用
包裹内容
而不是匹配父项
宽度和高度。您有android:layout\u width=“匹配父项”在水平线性布局的两个文本视图中
因此第一个文本视图
占据了所有的宽度。将其更改为wrap\u content
<TextView
android:id="@+id/ondergewichttekst"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textStyle="italic"
android:layout_marginTop="80dp"
android:gravity="center"
android:text="@string/ondergewichttekst"
android:textSize="16sp"/>
<TextView
android:id="@+id/ondergewicht"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textStyle="italic"
android:gravity="center"
android:layout_marginTop="1dp"
android:text="@string/ondergewicht"
android:textSize="30sp"/>
试试这个
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/ondergewicht"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="italic"
android:gravity="center"
android:layout_marginTop="1dp"
android:text="@string/ondergewicht"
android:textSize="30sp" />
<TextView
android:id="@+id/ondergewichttekst"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="italic"
android:layout_marginTop="80dp"
android:gravity="center"
android:text="@string/ondergewichttekst"
android:textSize="16sp" />
</LinearLayout>
试试这段代码。。。这对我来说很好
不,还是不明白?你能在IDE的图形视图中看到它们吗?不,我不能同时看到它们。只有文本。谢谢,标题现在在屏幕上。另一个答案进一步说明了这一点!谢谢你的努力!JacobI只是想提到,LinearLayout中元素的顺序决定了其在屏幕上的显示顺序。快乐编程:)
<?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="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/ondergewichttekst"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="italic"
android:layout_marginTop="80dp"
android:gravity="center"
android:text="@string/ondergewichttekst"
android:textSize="16sp"/>
<TextView
android:id="@+id/ondergewicht"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="italic"
android:gravity="center"
android:layout_marginTop="1dp"
android:text="@string/ondergewicht"
android:textSize="30sp"
/>
</LinearLayout>