答案 0 :(得分:0)
尝试在XML文件中使用/preceding-sibling::div[label[text()="Private"]]/input
和//div[label[normalize-space(text())="Field"] and input[@value="6 1012 49817"]]/preceding-sibling::div[label[text()="Private"]]/input
。
答案 1 :(得分:0)
如果我没有错,你想在TextView中添加一个透明的新行吗?
单个TextView无法实现这一点,因为SpannableString只会影响TextView的内容,Textview的背景与TextView的内容不同。 如果你必须实现这一点,那么你必须为TextView提供自定义实现,它将在自定义视图的onDraw方法中绘制透明背景,当它在文本内容中找到新行时。
或者其他选项是为每行文本呈现新的文本视图。
答案 2 :(得分:0)
嗨应该在布局中使用dynemically添加textview来完成,那时你必须设置textview的属性。你可以这样做
TvEx.java
public class TvEx extends Activity {
LinearLayout llMain;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.tv_ex);
llMain = (LinearLayout) findViewById(R.id.llmainTvEx);
final int N = 10; // total number of textviews to add
final TextView[] myTextViews = new TextView[N]; // create an empty
// array;
for (int i = 0; i < N; i++) {
// create a new textview
final TextView rowTextView = new TextView(this);
LinearLayout.LayoutParams buttonLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
buttonLayoutParams.setMargins(100, 20, 0, 0); // Set margins here
// set some properties of rowTextView or something
rowTextView.setText("This is row #" + i);
rowTextView.setBackgroundColor(Color.WHITE);
rowTextView.setLayoutParams(buttonLayoutParams);
// add the textview to the linearlayout
llMain.addView(rowTextView);
// save a reference to the textview for later
myTextViews[i] = rowTextView;
}
}
}
tv_ex.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:id="@+id/llmainTvEx"
android:layout_height="match_parent"
android:background="#A75653"
android:orientation="vertical"></LinearLayout>