2015-01-13 2 views
0

У меня есть несколько экранов ввода данных в моем приложении. В каждом из них последний EditText на экране не отображается. Он может использоваться в том случае, если вы можете нажать на него и набрать текст, но он также должен быть виден. Вот код для одного из экранов:последняя строка EditText исчезает

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/scrollView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.pdrestimator.Main_Activity$Car_Fragment"> 

    <RelativeLayout 
     android:id="@+id/relativeLayout" 
     android:layout_width="match_parent" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:paddingTop="@dimen/activity_vertical_margin" 
     android:layout_height="match_parent" 
     > 


     <TextView 
      android:id="@+id/vinLabel" 
      android:layout_alignParentTop="true" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_marginTop="12dp" 
      android:textSize="20dp" 
      android:focusable="true" 
      android:focusableInTouchMode="true" 
      android:text="VIN" /> 


     <EditText 
      android:id="@+id/vin" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@+id/carVinLabel" 
      android:layout_marginRight="10dp" 
      android:layout_marginLeft="140dp" 
      android:layout_alignBaseline="@+id/vinLabel" 
      android:ems="10" /> 




     <TextView 
      android:id="@+id/yearLabel" 
      android:layout_below="@+id/vinLabel" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textSize="20dp" 
      android:layout_alignParentLeft="true" 
      android:layout_marginTop="35dp" 
      android:focusable="true" 
      android:focusableInTouchMode="true" 
      android:text="Year" /> 


     <Spinner 
      android:id="@+id/year" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@+id/yearLabel" 
      android:layout_alignLeft="@+id/vin" 
      android:layout_alignRight="@+id/vin" 
      android:layout_alignBaseline="@+id/yearLabel" 
      android:ems="10" /> 



     <TextView 
      android:id="@+id/makeLabel" 
      android:layout_below="@+id/yearLabel" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:textSize="20dp" 
      android:layout_marginTop="48dp" 
      android:focusable="true" 
      android:focusableInTouchMode="true" 
      android:text="Make" /> 


     <AutoCompleteTextView 
      android:id="@+id/make" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@+id/yearLabel" 
      android:layout_alignLeft="@+id/vin" 
      android:layout_alignRight="@+id/vin" 
      android:layout_alignBaseline="@+id/makeLabel" 
      android:ems="10" /> 




     <TextView 
      android:id="@+id/modelLabel" 
      android:layout_below="@+id/makeLabel" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:textSize="20dp" 
      android:layout_marginTop="35dp" 
      android:focusable="true" 
      android:focusableInTouchMode="true" 
      android:text="Model" /> 


     <EditText 
      android:id="@+id/model" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@+id/modelLabel" 
      android:layout_alignLeft="@+id/vin" 
      android:layout_alignRight="@+id/vin" 
      android:layout_alignBaseline="@+id/modelLabel" 
      android:ems="10" /> 




     <TextView 
      android:id="@+id/colorLabel" 
      android:layout_below="@+id/modelLabel" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_marginTop="35dp" 
      android:textSize="20dp" 
      android:focusable="true" 
      android:focusableInTouchMode="true" 
      android:text="Color" /> 


     <AutoCompleteTextView 
      android:id="@+id/color" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@+id/colorLabel" 
      android:layout_alignLeft="@+id/vin" 
      android:layout_alignRight="@+id/vin" 
      android:layout_alignBaseline="@+id/colorLabel" 
      android:ems="10" /> 


     <TextView 
      android:id="@+id/manufactureDateLabel" 
      android:layout_below="@+id/colorLabel" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:textSize="20dp" 
      android:layout_marginTop="35dp" 
      android:focusable="true" 
      android:focusableInTouchMode="true" 
      android:text="Manuf. Date" /> 


     <EditText 
      android:id="@+id/manufactureDate" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@+id/manufactureDateLabel" 
      android:layout_alignLeft="@+id/vin" 
      android:layout_alignRight="@+id/vin" 
      android:layout_alignBaseline="@+id/manufactureDateLabel" 
      android:ems="10" /> 


     <TextView 
      android:id="@+id/stockNumberLabel" 
      android:layout_below="@+id/manufactureDateLabel" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:textSize="20dp" 
      android:layout_marginTop="35dp" 
      android:focusable="true" 
      android:focusableInTouchMode="true" 
      android:text="Stock Number" /> 


     <EditText 
      android:id="@+id/stockNumber" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@+id/stockNumberLabel" 
      android:layout_alignLeft="@+id/vin" 
      android:layout_alignRight="@+id/vin" 
      android:layout_alignBaseline="@+id/stockNumberLabel" 
      android:ems="10" /> 
    </RelativeLayout> 
</ScrollView> 

Любая помощь будет принята с благодарностью!

+0

Как вы нажмете на EditText, если его не видно? – Rohit5k2

+0

Я знаю, где это должно быть: справа от его метки, непосредственно внизу и выстроенного с помощью EditText над ним. Он есть, но строка, в которой находится курсор, не отображается. –

+0

Можете ли вы разместить «EditText' xml, которые видны вам? – Rohit5k2

ответ

1
<EditText 
      android:id="@+id/stockNumber" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@+id/stockNumberLabel" 
      android:layout_alignLeft="@+id/vin" 
      android:layout_alignRight="@+id/vin" 
      android:layout_alignBottom="@+id/stockNumberLabel" 
      android:ems="10" /> 

layout_alignBottom вместо базового делает трюк!

Worth looking at this

0

Используйте этот

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/scrollView" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.example.pdrestimator.Main_Activity$Car_Fragment"> 

<RelativeLayout 
    android:id="@+id/relativeLayout" 
    android:layout_width="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:layout_height="wrap_content" 
    > 


    <TextView 
     android:id="@+id/vinLabel" 
     android:layout_alignParentTop="true" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_marginTop="12dp" 
     android:textSize="20dp" 
     android:focusable="true" 
     android:focusableInTouchMode="true" 
     android:text="VIN" /> 


    <EditText 
     android:id="@+id/vin" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@+id/vinLabel" 
     android:layout_marginRight="10dp" 
     android:layout_marginLeft="140dp" 
     android:layout_alignBaseline="@+id/vinLabel" 
     android:ems="10" /> 




    <TextView 
     android:id="@+id/yearLabel" 
     android:layout_below="@+id/vinLabel" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="20dp" 
     android:layout_alignParentLeft="true" 
     android:layout_marginTop="35dp" 
     android:focusable="true" 
     android:focusableInTouchMode="true" 
     android:text="Year" /> 


    <Spinner 
     android:id="@+id/year" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@+id/yearLabel" 
     android:layout_alignLeft="@+id/vin" 
     android:layout_alignRight="@+id/vin" 
     android:layout_alignBaseline="@+id/yearLabel" 
     android:ems="10" /> 



    <TextView 
     android:id="@+id/makeLabel" 
     android:layout_below="@+id/yearLabel" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:textSize="20dp" 
     android:layout_marginTop="48dp" 
     android:focusable="true" 
     android:focusableInTouchMode="true" 
     android:text="Make" /> 


    <AutoCompleteTextView 
     android:id="@+id/make" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@+id/yearLabel" 
     android:layout_alignLeft="@+id/vin" 
     android:layout_alignRight="@+id/vin" 
     android:layout_alignBaseline="@+id/makeLabel" 
     android:ems="10" /> 




    <TextView 
     android:id="@+id/modelLabel" 
     android:layout_below="@+id/makeLabel" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:textSize="20dp" 
     android:layout_marginTop="35dp" 
     android:focusable="true" 
     android:focusableInTouchMode="true" 
     android:text="Model" /> 


    <EditText 
     android:id="@+id/model" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@+id/modelLabel" 
     android:layout_alignLeft="@+id/vin" 
     android:layout_alignRight="@+id/vin" 
     android:layout_alignBaseline="@+id/modelLabel" 
     android:ems="10" /> 




    <TextView 
     android:id="@+id/colorLabel" 
     android:layout_below="@+id/modelLabel" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_marginTop="35dp" 
     android:textSize="20dp" 
     android:focusable="true" 
     android:focusableInTouchMode="true" 
     android:text="Color" /> 


    <AutoCompleteTextView 
     android:id="@+id/color" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@+id/colorLabel" 
     android:layout_alignLeft="@+id/vin" 
     android:layout_alignRight="@+id/vin" 
     android:layout_alignBaseline="@+id/colorLabel" 
     android:ems="10" /> 


    <TextView 
     android:id="@+id/manufactureDateLabel" 
     android:layout_below="@+id/colorLabel" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:textSize="20dp" 
     android:layout_marginTop="35dp" 
     android:focusable="true" 
     android:focusableInTouchMode="true" 
     android:text="Manuf. Date" /> 


    <EditText 
     android:id="@+id/manufactureDate" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@+id/manufactureDateLabel" 
     android:layout_alignLeft="@+id/vin" 
     android:layout_alignRight="@+id/vin" 
     android:layout_alignBaseline="@+id/manufactureDateLabel" 
     android:ems="10" /> 


    <TextView 
     android:id="@+id/stockNumberLabel" 
     android:layout_below="@+id/manufactureDateLabel" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:textSize="20dp" 
     android:layout_marginTop="35dp" 
     android:focusable="true" 
     android:focusableInTouchMode="true" 
     android:text="Stock Number" /> 


    <EditText 
     android:id="@+id/stockNumber" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@+id/stockNumberLabel" 
     android:layout_alignLeft="@+id/vin" 
     android:layout_alignRight="@+id/vin" 
     android:layout_alignBottom="@+id/stockNumberLabel" 
     android:ems="10" /> 
</RelativeLayout> 

+0

Спасибо за ваши усилия, но это не сработало. Строка для нижнего EditText все еще не видна. –

+0

Когда вы попробовали его в своей системе с моим исходным кодом, сделал ли экран EditText? –

+0

Его видно здесь. Я попробовал это здесь. Попробуйте заменить полный xml. – Rohit5k2

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