4

プログラムで編集テキストフィールドをフェードアウトするための最良の方法は何でしょうか。

たとえば、編集テキストフィールドを次のように表示します。

ここに画像の説明を入力してください

現在、gimpを使用してフェードアウトする静止画像を使用していますが、すべてをフェード編集テキストフィールドに変更します。

どんな入力でも大歓迎です!

4

2 に答える 2

2

グラデーションでも同様の結果を得ることができます。

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" />

ドローアブルとグラデーションの詳細については、こちらをご覧ください

于 2012-08-01T16:04:58.087 に答える
1

これにはもっと簡単な答えがあると思います。それはコントロールに組み込まれています。画像サイズが非常に小さいため、これがまさにあなたが望んでいたものであるかどうかを判断するのは難しいです。

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);  
于 2014-09-20T19:45:40.440 に答える