プログラムで編集テキストフィールドをフェードアウトするための最良の方法は何でしょうか。
たとえば、編集テキストフィールドを次のように表示します。
現在、gimpを使用してフェードアウトする静止画像を使用していますが、すべてをフェード編集テキストフィールドに変更します。
どんな入力でも大歓迎です!
プログラムで編集テキストフィールドをフェードアウトするための最良の方法は何でしょうか。
たとえば、編集テキストフィールドを次のように表示します。
現在、gimpを使用してフェードアウトする静止画像を使用していますが、すべてをフェード編集テキストフィールドに変更します。
どんな入力でも大歓迎です!
グラデーションでも同様の結果を得ることができます。
shape
まず、要素を使用してドローアブルforlderxmlファイルを作成します。次に例を示します。
<!-- mygradient.xml -->
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="@color/black" />
<gradient
android:angle="90"
android:centerColor="@color/grey"
android:endColor="@color/white"
android:startColor="@color/black"
android:type="linear" />
</shape>
次に、いくつかのビューの背景としてxmlを使用します。
<TextView
android:background="@drawable/mygradient"
android:layout_height="wrap_content"
android:layout_width="wrap_content" />
ドローアブルとグラデーションの詳細については、こちらをご覧ください
これにはもっと簡単な答えがあると思います。それはコントロールに組み込まれています。画像サイズが非常に小さいため、これがまさにあなたが望んでいたものであるかどうかを判断するのは難しいです。
EditTextsのフェードに関する詳細情報を探していたときにこれを見つけたので、受け入れられた答えは非常に複雑なので、すでに知っていることを共有したいと思いました。
EditText textbox = (EditText) findViewById(R.id.textbox);
// This enables the fading automatically.
// Use Horizontal if you want the sides to fade!
textbox.setVerticalFadingEdgeEnabled(true);
// This allows you to change to depth of the fade
// Low values like 10 has an incredible small fade, but values like 100 seem to be really good!
textbox.setFadingEdgeLength(100);