【发布时间】:2019-02-27 05:44:08
【问题描述】:
android:textColor 似乎不适用于嵌套的LinearLayout 内的TextView。我查看了Textcolor selector not working 的问题。但它也不适用于我的情况。以下是我的布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".CreateActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="15dp">
<TextView
android:id="@+id/lblTitle"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="end"
android:layout_weight="0.9"
android:hint="Title:"
android:textAlignment="textEnd"
android:textSize="24sp"
android:textColor="#000000"/>
<EditText
android:id="@+id/lblTitleEdit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:hint="Enter your title here"
android:layout_weight="0.4"
android:inputType="text"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="15dp">
<TextView
android:id="@+id/lblVenue"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="end"
android:layout_weight="0.9"
android:hint="Venue:"
android:textAlignment="textEnd"
android:textSize="24sp"
android:textColor="#000000"/>
<EditText
android:id="@+id/lblVenueEdit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:hint="Enter your venue here"
android:layout_weight="0.4"
android:inputType="text"/>
</LinearLayout>
</LinearLayout>
我在这里犯了什么错误吗? 任何帮助将不胜感激。
【问题讨论】:
-
使用 android:text="Title:" 代替 android:hint="Title:"
-
感谢您的指出。我已经看过一个问题,但它对我不起作用。因此,在发布问题时,我在描述中添加了该解决方案对我不起作用的问题。无论如何,我发现了我的错误。我使用的是
android:hint而不是android:text
标签: android textview textcolor