1

My UI is

UserName : Textfield

Password : Textfield

Button

I am making simple UI in android .Actually I am facing few problem

1) Edit field is not scrolling horizontally if the text come more it comes down .

2) password is shown .

3) If I want to show this in pop up screen mean a small window how it is possible ?

<TextView
    android:id="@+id/username"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="31dp"
    android:layout_marginTop="108dp"
    android:textSize="12sp"
    android:textStyle="bold"
    android:text="UserName" />

<EditText
    android:id="@+id/usename_edit"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/username"
    android:layout_alignBottom="@+id/username"
    android:layout_marginLeft="35dp"
    android:layout_toRightOf="@+id/username"
    android:ems="10" >

    <requestFocus />
</EditText>

<TextView
    android:id="@+id/username_password"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/username"
    android:layout_below="@+id/usename_edit"
    android:layout_marginTop="28dp"
     android:textStyle="bold|italic"
    android:text="Password" />

<EditText
    android:id="@+id/edit_password"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/username_password"
    android:layout_alignBottom="@+id/username_password"
    android:layout_alignLeft="@+id/usename_edit"
    android:ems="10" />

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/edit_password"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="62dp"
    android:textStyle="bold"
    android:text="ClickMe" />

4 Answers4

1

Answer 1:

add this line in your java code where the text view is defined

textview.setMovementMethod(new ScrollingMovementMethod());

and add this in your xml file

 android:fadeScrollbars="false"
 android:scrollbars="horizontal"

Answer 2:

For your password EditText add this line in your xml file

 android:inputType="textPassword"

Answer 3:

Use Dialog for the same. Something like this

myDialog = new Dialog(Login.this);
            myDialog.setContentView(R.layout.emailpop);
            myDialog.setTitle("Login");
            myDialog.setCancelable(true);

            et_f = (EditText) myDialog.findViewById(R.id.et_pass);
            et_f.setText(et1.getText().toString());
            t5 = (TextView) myDialog.findViewById(R.id.textView4);
            t5.setVisibility(View.GONE);

            // for OK
            Button ok = (Button) myDialog.findViewById(R.id.button1);
            ok.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {


            });
            myDialog.show();
Droid
  • 419
  • 4
  • 15
0

try this by code..

usename_edit.setHorizontalScrollBarEnabled(true);

and

edit_password.setHorizontalScrollBarEnabled(true);

there is also can done from xml by setting scrollbars prop. of edittext

 scrollbars="horizonatal"

for password problem set this prop. to editext in xml:

android:inputType="textPassword"
Kalpesh Lakhani
  • 1,003
  • 14
  • 28
0

1) Edit field is not scrolling horizontally if the text come more it comes down .

Add an attribute to your EditText as android:singleLine="true"

2) password is shown .

Add an attribute to your as android:inputType="textPassword" to the edit_password

3) If I want to show this in pop up screen mean a small window how it is possible

You'll need an AlertDialog for this. Checkout this tutorial.

bakriOnFire
  • 2,685
  • 1
  • 15
  • 27
0

1) to make it scrollable use: .setHorizontalScrollBarEnabled(true); in your activity class, or this scrollbars="horizonatal" in your edittext xml.

2) to make the password *****: use android:inputType="textPassword" in your edittext xml.

3) to show a popup, you can use alertDialog.

Ahmed Ekri
  • 4,601
  • 3
  • 23
  • 42