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;
}
};
<?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>
これを使用するだけで、ボタンと最初のTextView –
この質問はダウン受信し続けますあなたが質問を編集し、あなたの問題が何であるかを説明する図や画像を追加するまで投票します – Yogesh
を提出していない私はのEditTextフィールドにscrollviewを与えたい –