Material Desain Android sesi -2 ( Floating Label )

Saturday, January 23, 2016 Unknown 0 Comments


kembali jumpa sobat... meneruskan artikel sebelumnya mengenai material desain.. kali saya akan menulis mengenai Floating label untuk edittext untuk penjelasanya mengenai Floating label dilihat pada web android developer

Untuk teman2 yang telah mengikuti artikel mengenai material desain bisa membuka kembali projectnya.

setelah project yang ada pada android studio telah terbuka ikuti langkah2 berikut :

buat Floating label pada file yang kalian inginkan berikut scriptnya:

<LinearLayout
            android:layout_marginTop="?attr/actionBarSize"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:text="Material Design EditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textStyle="bold"
                style="@style/Base.TextAppearance.AppCompat.Title"
                android:layout_margin="20dp"/>

            <android.support.design.widget.TextInputLayout
                android:id="@+id/input_layout_email"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="20dp">
                <EditText
                    android:id="@+id/input_email"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/hint_email" />
            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                android:id="@+id/input_layout_password"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="20dp">
                <EditText
                    android:id="@+id/input_password"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/hint_password" />
            </android.support.design.widget.TextInputLayout>

            <Button
                android:id="@+id/btn_send"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/btn_send"
                android:layout_margin="20dp"/>

        </LinearLayout>



untuk memanggil pemanggilan layout floating dilakukan pada file java di method onCreate berikut scriptnya :

        TextInputLayout layoutEmail = (TextInputLayout) findViewById(R.id.input_layout_email);
        TextInputLayout layoutPassword = (TextInputLayout) findViewById(R.id.input_layout_password);
        EditText inputEmail = (EditText) findViewById(R.id.input_email);
        EditText inputPassword = (EditText) findViewById(R.id.input_password);
        Button btnSend = (Button) findViewById(R.id.btn_send);


bila tidak ada yang error makan hasilnya akan seperti dibawah

0 comments: