我正在尝试这个,但它对我不起作用
Paint p = new Paint();
p.setColor(ContextCompat.getColor(textView.getContext(),android.R.color.holo_red_dark));
textView.setPaintFlags(p.getColor());
textView.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
答案 0 :(得分:1)
试试这个,
package test.listchangelistener;
import java.util.Arrays;
import java.util.List;
import javafx.beans.Observable;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.util.Callback;
public class listChangeDemo {
public static void main(String[] args) {
Person p1 = new Person("Ted", 26);
Person p2 = new Person("Anne", 19);
// just a simple list
List<Person> persons = Arrays.asList(p1, p2);
// extractor to observe change of person properties
Callback<Person, Observable[]> extractor = (Person p) -> {
return new Observable[]{
p.ageProperty(),
p.nameProperty()
};
};
// make list observable and attach extractor
ObservableList<Person> observablePersons = FXCollections.observableList(persons, extractor);
// create listchangeListener for observableList
ListChangeListener listener = (ListChangeListener) (ListChangeListener.Change c) -> {
while (c.next()) {
if (c.wasAdded()) {
System.out.println("these were added: ");
List addedSubList = c.getAddedSubList();
addedSubList.forEach((Object t) -> {
System.out.println("added Person: " + t);
});
} else if (c.wasRemoved()) {
System.out.println("these were removed");
List removedSubList = c.getRemoved();
removedSubList.forEach((Object t) -> {
System.out.println("removed Person: " + t);
});
} else if (c.wasUpdated()) {
System.out.println("these were updated");
System.out.println("Updated elements are: "
+ c.getList().subList(c.getFrom(), c.getTo()));
}
}
};
// attach listchangeListener to observableList
observablePersons.addListener(listener);
// testing changes
observablePersons.add(new Person("Siegfried", 10));
}
}
了解更多信息,请参阅this问题。
答案 1 :(得分:0)
edittext.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_IN);
答案 2 :(得分:0)
在drawable文件夹中创建一个under_line.xml文件,然后设置你的textview背景,如android:background =&#34; @ drawable / under_line&#34;
将此xml添加到drawable文件夹uder_line.xml
中
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:bottom="-15dp">
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="0.5"
android:pivotY="0.5"
android:toDegrees="0">
<shape android:shape="line">
<stroke
android:width="1dp"
android:color="@android:color/holo_red_dark" />
</shape>
</rotate>
</item></layer-list>
然后像这样设置你的布局文本视图背景
机器人:背景=&#34; @可绘制/ under_line&#34;