2015-05-07 3 views
0

У меня есть следующий макет для страницы входа, мне нужно уменьшить расстояние между каждым элементом, короче, мне нужно переместить имя пользователя, пароль и кнопку входа вверх по экрану, что когда мы открываем виртуальную клавиатуру, кнопка входа должна быть видимой всегда, я попытался использовать «margintop = -negative value», ее не удалось.Изменение дизайна страницы входа в систему, чтобы всегда была видна кнопка входа в систему

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:andriod="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/loginbackmain" 
    android:orientation="vertical"> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="5dp" 
     android:orientation="vertical" > 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:src="@drawable/ic_launcher" /> 
    </LinearLayout> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="5dp" 
     android:layout_weight="1" 
     android:gravity="top" 
     android:orientation="vertical" > 
     <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="10dp" 
     android:gravity="top" 
     android:background="@drawable/loginformback" 
     android:orientation="vertical" 
     android:weightSum="1"> 

      <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" > 

      <EditText 
       android:id="@+id/editText1" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_margin="15dp" 
       android:layout_weight="1" 
       android:drawableLeft="@android:drawable/ic_menu_day" 
       android:ems="10" 
       android:hint="username" > 

       <requestFocus /> 
      </EditText> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:layout_marginTop="-30dp"> 

      <EditText 
       android:id="@+id/editText2" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_margin="15dp" 
       android:drawableLeft="@android:drawable/ic_menu_day" 
       android:ems="10" 
       android:hint="password" 
       android:inputType="textPassword" /> 
     </LinearLayout> 


     <Button 
      android:id="@+id/button1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_margin="5dp" 
      android:onClick="login" 
      android:text="Login" 
      andriod:background="#A0522D"/> 
      <ProgressBar 
       android:id="@+id/progressBar1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:visibility="invisible" 
       /> 

     </LinearLayout> 
</LinearLayout> 
</LinearLayout> 

ответ

1

Set

android:windowSoftInputMode="stateVisible|adjustPan" 

в Android файле манифеста внутри тега

+0

мне нужен только для конкретной страницы, которая экрана входа в систему, можно обращаться? – jenil

+0

Да, вы можете указать тег только для экрана входа внутри файла манифеста –

+0

Его изменение размера всех элементов, кнопка выглядит как одна строка, мне нужен внешний вид, если она ... после открытия клавиатуры – jenil

Смежные вопросы