0

EditTextにテキストを入力しようとしています。私はEditText自体を汚すことに成功しましたが、その内容は汚染されませんでした。 EditTextのテキストのフォントの太さ、フォントの色、スタイルなどを変更するにはどうすればよいですか?Androidの中でテキスト(コンテンツ)を編集するには

これは私がEditText表示スタイル方法です:その後、私はそれを呼び出す

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" 
    android:paddingBottom="10dp" 
    android:paddingLeft="42dp" 
    android:paddingRight="10dp" 
    android:paddingTop="10dp"> 
    <item android:bottom="3dp"> 
     <bitmap 
      android:gravity="center_vertical|left" 
      android:src="@drawable/ic_games_black_24dp" /> 
     <shape android:shape="rectangle"> 
      <stroke 
       android:width="1dp" 
       android:color="#37474f" /> 
     </shape> 
    </item> 
</layer-list> 

を:

EditText editText = new EditText(mContext); 
editText.setHint(" Find"); 
editText.setWidth(555); 
editText.setBackgroundResource(R.drawable.add_new_bag_dr); 

それについて移動する最良の方法は何ですか?どのようなオプションがありますか?

UPDATE

にはどうすればビューにXMLで定義されたスタイルを添付することができますか?

+0

これを確認してください。https://stackoverflow.com/questions/3078081/setting-global-styles-for-views-in-android – Shailesh

答えて

1

次のものを使用することができます。

editText.setTextColor("set the color you want"); 

はstyle.xmlであなたのカスタムスタイルを定義して、

editText.setTextAppearance(R.style.yourCustomStyle); 

を使用し、それがお役に立てば幸いです!

+0

reply @sumitに感謝します。 XMLで定義されたスタイルをビューにアタッチするにはどうすればよいですか? –

関連する問題