2015-03-05 5 views
0

Я делаю приложение для Android, чтобы ввести информацию о пользователе, для этого у меня есть две кнопки и наборщик, моя кнопка настраивается и не отображается ни в предварительном просмотре в студии Android, ни в эмулятореAndroid: кнопки не видны в scrollview

Вот мой код

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    tools:context="com.app.tarun.dc2.Fragments.AddressFragment"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:paddingTop="@dimen/activity_vertical_margin" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     android:orientation="vertical" 
     > 


     <!--Layout for Buttons--> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:orientation="horizontal" 
      > 


      <com.app.tarun.dc2.CustomViews.SquareLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_margin="25dp" 
       android:layout_weight="1"> 

       <ImageButton 
        android:src="@drawable/ic_add" 
        android:id="@+id/medicineEditAddButton" 
        android:scaleType="fitCenter" 
        android:padding="20dp" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:background="@drawable/green_button_style"/> 


      </com.app.tarun.dc2.CustomViews.SquareLayout> 

      <NumberPicker 
       android:layout_width="0dp" 
       android:id="@+id/medicineEditNumberPicker" 
       android:layout_height="wrap_content" 
       android:layout_weight="1"> 

      </NumberPicker> 

      <com.app.tarun.dc2.CustomViews.SquareLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_margin="25dp" 
       android:layout_weight="1"> 

       <ImageButton 
        android:src="@drawable/ic_continue" 
        android:id="@+id/medicineEditContinueButton" 
        android:scaleType="fitCenter" 
        android:padding="20dp" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:background="@drawable/yellow_button_style"/> 


      </com.app.tarun.dc2.CustomViews.SquareLayout> 

     </LinearLayout> 


<!--Horizontal Linear Layout for EDITTEXT--> 
<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:hint="First Name" 
     android:inputType="text" 
     android:layout_marginTop="25dp"/> 


    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:hint="Last Name" 
     android:inputType="text" 
     android:layout_marginTop="25dp"/> 


</LinearLayout> 
<!--Horizontal Linear Layout for EDITTEXT end here(First name and last name--> 
</LinearLayout></ScrollView> 
+0

Марку 'RelativeLayout' в качестве родительского макета, а затем положить' ScrollView' в нем. Затем в вас ** manifest.xml ** добавьте свойство 'android: windowSoftInputMode =" adjustPan | adjustResize "' в этом действии. Также вы можете опубликовать скриншот? –

ответ

0

Try включая ваш взгляд прокрутки в макете. Вот как я достиг его для проекта шахты:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="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" 
    tools:context="com.com.atr.LoginActivity" > 

    <ScrollView 
     android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    > 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="" 
     android:id="@+id/txthello"></TextView> 

    <EditText 
     android:id="@+id/txtApp" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 

     android:layout_below="@+id/txthello" 
     android:layout_marginTop="18dp" 
     android:hint="Enter Application Code"/> 

     <EditText 
     android:id="@+id/txtModuleId" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 

     android:layout_below="@+id/txtApp" 
     android:layout_marginTop="18dp" 
     android:hint="Enter Module Id"/> 

     <EditText 
     android:id="@+id/txtModuleCode" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 

     android:layout_below="@+id/txtModuleId" 
     android:layout_marginTop="18dp" 
     android:hint="Enter Module Code"/> 

      <EditText 
     android:id="@+id/txtModuleType" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 

     android:layout_below="@+id/txtModuleCode" 
     android:layout_marginTop="18dp" 
     android:hint="Enter Module Type"/> 
      <EditText 
     android:id="@+id/txtSubModuleId" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 

     android:layout_below="@+id/txtModuleType" 
     android:layout_marginTop="18dp" 
     android:hint="Enter Sub Module Id"/> 

     <EditText 
     android:id="@+id/txtSubModuleCode" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 

     android:layout_below="@+id/txtSubModuleId" 
     android:layout_marginTop="18dp" 
     android:hint="Enter Sub Module Code"/> 

     <EditText 
     android:id="@+id/txtUserId" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 

     android:layout_below="@+id/txtSubModuleCode" 
     android:layout_marginTop="18dp" 
     android:hint="Enter User Id"/> 

     <EditText 
     android:id="@+id/txtDateFrom" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 

     android:layout_below="@+id/txtUserId" 
     android:layout_marginTop="18dp" 
     android:hint="From Date (mmm-dd-yyyy)"/> 

      <EditText 
     android:id="@+id/txtDateTo" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 

     android:layout_below="@+id/txtDateFrom" 
     android:layout_marginTop="18dp" 
     android:hint="To Date (mmm-dd-yyyy)"/> 

      <Button 
     android:id="@+id/btnCallService" 
     android:layout_width="80dp" 
     android:layout_height="45dp" 

     android:layout_below="@+id/txtDateTo" 
     android:layout_toRightOf="@+id/txtDateTo" 
     android:layout_marginTop="18dp" 

     android:layout_alignParentLeft="true" 
     android:text="Send"/> 
    </RelativeLayout> 
    </ScrollView> 
</RelativeLayout> 

Просто чтобы дать вам основную идею :)

0

Изменение ширины заказного макета от 0dp обернуть содержание/match_parent в зависимости от вашего необходимость. Я думаю, что это может решить вашу проблему. У меня есть отредактированный макет внизу.

<com.app.tarun.dc2.CustomViews.SquareLayout 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_margin="25dp" 
      android:layout_weight="1"> 

      <ImageButton 
       android:src="@drawable/ic_add" 
       android:id="@+id/medicineEditAddButton" 
       android:scaleType="fitCenter" 
       android:padding="20dp" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="@drawable/green_button_style"/> 


     </com.app.tarun.dc2.CustomViews.SquareLayout> 

     <NumberPicker 
      android:layout_width="wrap_content" 
      android:id="@+id/medicineEditNumberPicker" 
      android:layout_height="wrap_content" 
      android:layout_weight="1"> 

     </NumberPicker> 

     <com.app.tarun.dc2.CustomViews.SquareLayout 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_margin="25dp" 
      android:layout_weight="1"> 

      <ImageButton 
       android:src="@drawable/ic_continue" 
       android:id="@+id/medicineEditContinueButton" 
       android:scaleType="fitCenter" 
       android:padding="20dp" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="@drawable/yellow_button_style"/> 


     </com.app.tarun.dc2.CustomViews.SquareLayout> 
0

Добавить андроида: weightSum = "[любой Int]" на первый LinearLayout

0

ScrollView является FrameLayout, что означает you should place one child в нем, содержащий все содержимое для прокрутки; этот ребенок сам может быть менеджером компоновки со сложной иерархией объектов.

Итак, здесь вы должны взять LinearLayout или RelativeLayout, а затем вы должны поместить другую иерархию компонента.

<ScrollView android:layout_width="match_parent" 
android:layout_height="match_parent" 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
tools:context="com.app.tarun.dc2.Fragments.AddressFragment"> 

<LinearLayout android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:orientation="vertical" 
    > 


    <!--Layout for Buttons--> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:orientation="horizontal" 
     > 


     <com.app.tarun.dc2.CustomViews.SquareLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_margin="25dp" 
      android:layout_weight="1"> 

      <ImageButton 
       android:src="@drawable/ic_add" 
       android:id="@+id/medicineEditAddButton" 
       android:scaleType="fitCenter" 
       android:padding="20dp" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="@drawable/green_button_style"/> 


     </com.app.tarun.dc2.CustomViews.SquareLayout> 

     <NumberPicker 
      android:layout_width="0dp" 
      android:id="@+id/medicineEditNumberPicker" 
      android:layout_height="wrap_content" 
      android:layout_weight="1"> 

     </NumberPicker> 

     <com.app.tarun.dc2.CustomViews.SquareLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_margin="25dp" 
      android:layout_weight="1"> 

      <ImageButton 
       android:src="@drawable/ic_continue" 
       android:id="@+id/medicineEditContinueButton" 
       android:scaleType="fitCenter" 
       android:padding="20dp" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="@drawable/yellow_button_style"/> 


     </com.app.tarun.dc2.CustomViews.SquareLayout> 

    </LinearLayout> 


<!--Horizontal Linear Layout for EDITTEXT--> 
<LinearLayout 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:orientation="horizontal"> 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:hint="First Name" 
     android:inputType="text" 
     android:layout_marginTop="25dp"/> 


    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:hint="Last Name" 
     android:inputType="text" 
     android:layout_marginTop="25dp"/> 


</LinearLayout> 
<!--Horizontal Linear Layout for EDITTEXT end here(First name and last name--> 

</LinearLayout> 

</LinearLayout></ScrollView> 

Надеюсь, что этот код работает для вас.

И вы также можете посетить эту ScrollView

+0

вы можете использовать только один тег в прокрутке. вы поместили все теги непосредственно в одиночный linearlayout или relativelayout, а затем нажмите кнопку и edittext ... –

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