2016-03-05 18 views

回答

1

我發現Soultion這一點。我在我的代碼中執行此操作

<!-- Firstly Make a Xml of TextInputLayout and Edittext Layout --> 

<!-- Text Input Layout--> 
<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:textAppearance="?android:attr/textAppearanceLarge" 
app:errorTextAppearance="@style/TextLabelInput" 
/> 


<!-- Edittext Layout --> 
<?xml version="1.0" encoding="utf-8"?> 
<EditText xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:textColor="@color/txt_color" 
android:textColorHint="@color/txt_color" 
android:textColorHighlight="@color/txt_color" 
android:textSize="21sp" /> 


<!-- In code add this with dynamic Text --> 

TextInputLayout input 

input = new TextInputLayout(this); 
    input =(TextInputLayout)getLayoutInflater().inflate(R.layout.row_inputlayout_item, null); 

input.setLayoutParams(lparams); 
input.setTypeface(tf); 


et= new EditText(this); 
et= (EditText)getLayoutInflater().inflate(R.layout.row_edittext_form, null); 
et.setId(Integer.parseInt(item.getFieldid())); 
et.setLayoutParams(lparams); 
et.setHint(item.getLabel()); 
input.addView(et); 
rl_MainLayout1.addView(input); 
1

你必須使用定義自定義樣式,這行添加到您的TextInputLayoutapp:errorTextAppearance="@style/custom_textColor_style"

+0

我在XMl中使用了這個但我希望通過在Java編碼中實際使用 –