2017-07-22 1 views
-5

edittextフィールドのみにscrollviewを渡す必要がある このレイアウトでは、私はedittextを使用しています。アンドロイド内のedittextのみにスクロール表示を与える

View.OnTouchListener touchListener = new View.OnTouchListener() 
{ 
     public boolean onTouch(final View v, final MotionEvent motionEvent) 
{ 
      v.getParent().requestDisallowInterceptTouchEvent(true); 
      switch (motionEvent.getAction() & MotionEvent.ACTION_MASK) 
{ 
       case MotionEvent.ACTION_UP: 
        v.getParent().requestDisallowInterceptTouchEvent(false); 
        break; 
      } 
      return false; 
     } 
    }; 

See here is image

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:card_view="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbarforprofile" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/colorPrimaryDark" 
     android:minHeight="?attr/actionBarSize" 
     android:titleTextColor="#ffffff" 
     app:theme="@style/ToolbarColoredBackArrow" /> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 


     <ImageView 
      android:layout_width="100dp" 
      android:layout_height="100dp" 
      android:layout_gravity="center" 
      android:layout_marginBottom="-80dp" 
      android:layout_marginTop="16dp" 
      android:elevation="2dp" 
      android:padding="16dp" 
      android:src="@drawable/electricle" /> 


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

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="18dp" 
       android:drawableLeft="@drawable/leftarrow" 

       android:textColor="@color/demo" 
       android:textSize="0sp" /> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="-65.5dp" 
       android:layout_marginRight="18dp" 
       android:layout_marginTop="18dp"> 


       <LinearLayout 
        android:id="@+id/profile_details" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="vertical"> 

        <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:background="@color/demo" 

         android:orientation="vertical" 
         android:padding="16dp"> 

         <TextView 
          android:id="@+id/txtservicedetails" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:layout_marginBottom="20dp" 
          android:layout_marginTop="40dp" 
          android:gravity="center" 
          android:text="@string/app_name" 
          android:textColor="#fff" 
          android:textSize="20sp" 
          android:textStyle="bold" /> 

         <android.support.v4.widget.NestedScrollView 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

          <LinearLayout 
           android:layout_width="match_parent" 
           android:layout_height="wrap_content" 
           android:layout_gravity="center" 
           android:layout_marginTop="10dp" 
           android:orientation="vertical"> 


           <EditText 
            android:id="@+id/editText_requirement" 
            android:layout_width="match_parent" 
            android:layout_height="70dp" 
            android:layout_margin="3dp" 
            android:background="#fff" 
            android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 " 
            android:gravity="top" 

            android:hint="Your Requirement (optional)" 
            android:inputType="textMultiLine|textCapSentences" 
            android:padding="6dp" 
            android:textColor="#000" /> 

           <DatePicker 
            android:id="@+id/datePicker" 
            android:layout_width="wrap_content" 
            android:layout_height="match_parent" 
            android:visibility="gone" /> 

           <EditText 
            android:id="@+id/et_dateof_visit" 
            android:layout_width="match_parent" 
            android:layout_height="40dp" 
            android:layout_margin="5dp" 

            android:background="#fff" 
            android:focusable="false" 
            android:hint="Date Of Visit" 
            android:inputType="date" 
            android:maxLines="1" 
            android:padding="5dp" 
            android:textColor="#000" /> 

           <EditText 
            android:id="@+id/et_time" 
            android:layout_width="match_parent" 
            android:layout_height="40dp" 
            android:layout_margin="5dp" 
            android:background="#fff" 
            android:focusable="false" 
            android:hint="Time Of Visit" 
            android:inputType="time" 
            android:maxLines="1" 
            android:padding="5dp" 
            android:textColor="#000" /> 

           <EditText 

            android:id="@+id/et_noofperson" 
            android:layout_width="match_parent" 
            android:layout_height="40dp" 
            android:layout_margin="5dp" 
            android:background="#fff" 
            android:focusable="true" 
            android:hint="No Of Person You Need" 
            android:inputType="number" 
            android:maxLength="2" 
            android:maxLines="1" 
            android:padding="5dp" 
            android:singleLine="true" 
            android:text="" /> 

           <EditText 

            android:id="@+id/et_serviceaddress" 
            android:layout_width="match_parent" 
            android:layout_height="70dp" 
            android:layout_margin="5dp" 
            android:background="#fff" 
            android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890/-,: " 
            android:focusable="true" 
            android:gravity="top" 
            android:hint="Service Address" 
            android:inputType="textMultiLine|textCapSentences" 
            android:maxLines="4" 
            android:padding="10dp" 
            android:singleLine="true" 
            android:text="" /> 


          </LinearLayout> 
         </android.support.v4.widget.NestedScrollView> 


        </LinearLayout> 

        <RelativeLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_gravity="center" 
         android:layout_marginBottom="20dp" 
         android:layout_marginTop="-20dp" 
         android:gravity="center"> 

         <Button 
          android:id="@+id/btn_submit" 
          style="@style/Widget.AppCompat.Button.Colored" 
          android:layout_width="wrap_content" 
          android:layout_height="45dp" 
          android:layout_gravity="center" 
          android:layout_marginTop="20dp" 
          android:background="@drawable/rounded_green" 
          android:ems="10" 
          android:gravity="center" 
          android:text="Submit" 
          android:textSize="20dp" 
          android:textStyle="bold" /> 

         <ProgressBar 
          android:id="@+id/btnsubmit" 
          android:layout_width="30dp" 
          android:layout_height="30dp" 
          android:layout_centerInParent="true" 
          android:layout_gravity="center" 
          android:visibility="gone" /> 

        </RelativeLayout> 


       </LinearLayout> 


      </LinearLayout> 

     </LinearLayout> 


    </LinearLayout> 

</LinearLayout> 
+0

これを使用するだけで、ボタンと最初のTextView –

+0

この質問はダウン受信し続けますあなたが質問を編集し、あなたの問題が何であるかを説明する図や画像を追加するまで投票します – Yogesh

+0

を提出していない私はのEditTextフィールドにscrollviewを与えたい –

答えて

0

このように、以下のものを試してみてください、私はこれは、すべての最高のあなたを助けることを願っています。

0

私はあなたの質問を正しく理解しているかどうかまだ分かりません。私はあなたがEditText(s)をスクロールさせたいと思っていて、トップはTextView、下はButtonに固定しているとします。

これを試してください。最初にLinearLayoutをプライマリコンテナとして、子レイアウトとしてTextViewScrollView、およびButtonを追加します。

スクロールする必要があるEditTextはすべて、子として追加されたLinearLayoutに追加することができます(ScrollView)。

このコード

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:card_view="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbarforprofile" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/colorPrimaryDark" 
     android:minHeight="?attr/actionBarSize" 
     android:titleTextColor="#ffffff"/> 

    <ImageView 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:layout_gravity="center" 
     android:layout_marginTop="16dp" 
     android:layout_marginBottom="16dp"/> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:textAlignment="center" 
     android:text="@string/app_name"/> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 

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

      <!--Put all your scrollable content in here--> 

      <EditText 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 
      <EditText 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 
      <EditText 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 
      <EditText 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 

     </LinearLayout> 

    </ScrollView> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center"/> 

</LinearLayout> 

をチェックアウト私はButtonは常に一番下にとどまることを確認するためにScrollViewlayout_weight性を付与しています。

PS:必要な解決策ではない場合は、コメントを残してください。

0

アンドロイド:scrollHorizo​​ntally =「true」をあなたはすべてであなたが望むものについて明確ではありません

関連する問題