我有一个问题要问你们。当我在eclipse中的xml文件中有一个简单的文本时。为什么标题不显示?
我搜索过类似的问题,但在stackoverflow上找不到它。希望有人可以帮助我。
不幸的是,我无法发布图片。那么,文本:@ string / ondergewicht是文本的标题。@ / string / ondergewichttekst是我用过的文字。
这是我用过的代码。对不起,如果这是一个愚蠢的问题,我相信它是..
<?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,但是overgewichts不是。也许有类似文字顺序的东西?
希望有人可以帮助我。
雅各
答案 0 :(得分:1)
试试这段代码......对我来说很好。
<?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>
答案 1 :(得分:0)
您的线性布局中有水平方向,而您的第一个TextView有layout_width = match_parent
这没有意义,第二个TextView没有空间。
使用布局的垂直方向或使用wrap_content
代替match_parent
宽度和高度。
答案 2 :(得分:0)
android:layout_width="match_parent"
TextView
的{{1}}段中horizontal
LinearLayout
,因此第一个TextView
占据了所有width
。将它们更改为wrap_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"/>
答案 3 :(得分:0)
试试这个
<?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>