私のレイアウトでは、そのスクロール可能な編集テキストでスクロール・ビューを持っています。setOnTouchListener
を使用して作業しています。 問題は、ユーザーがedittextを入力するとレイアウトの一番上に移動し、ユーザーは編集テキストフィールドを見ることができません。 ユーザーが入力すると、両方のスクロールが機能しています。 私は、レイアウトスクロールを停止する必要があるテキストを編集するときにユーザーがクリックされたときに解決すると思います。テキストを編集してユーザーに表示され、ユーザーが入力すると移動しません。誰でも私を助けてください。スクロールビューで編集テキストはスクロールしていますが、編集したテキストでは行数を入力していない場合、ユーザーは編集テキストを見ることができません。
レイアウトコード: -
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
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">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Welcome To Register Page"
android:textSize="20dp"
android:textStyle="bold"
android:id="@+id/title"
android:textColor="@android:color/holo_blue_bright"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:id="@+id/lin1"
android:background="@drawable/shape">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Personal Details"
android:gravity="center"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First Name :"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/fname"
android:inputType="textCapSentences"
android:imeOptions="actionNext"
android:layout_marginLeft="5dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Last Name :"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lname"
android:inputType="textCapSentences"
android:imeOptions="actionNext"
android:layout_marginLeft="5dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Phone No :"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/pno"
android:inputType="number"
android:imeOptions="actionNext"
android:layout_marginLeft="5dp"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/lin1"
android:id="@+id/lin2"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:background="@drawable/shape">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Address"
android:gravity="center"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="City/Town :"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/city"
android:inputType="textCapSentences"
android:imeOptions="actionNext"
android:layout_marginLeft="5dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="State :"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/state"
android:inputType="textCapSentences"
android:imeOptions="actionNext"
android:layout_marginLeft="5dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Country :"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/country"
android:inputType="textCapSentences"
android:imeOptions="actionNext"
android:layout_marginLeft="5dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Zip Code :"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/zipcode"
android:inputType="number"
android:imeOptions="actionNext"
android:layout_marginLeft="5dp"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lin3"
android:layout_below="@id/lin2"
android:orientation="vertical"
android:layout_marginTop="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Enter Full Address"
android:gravity="center"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="10"
android:lines="10"
android:maxEms="1000"
android:scrollbars="vertical"
android:layout_marginTop="5dp"
android:id="@+id/address"
android:gravity="top"
android:background="@drawable/shape"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lin4"
android:layout_below="@id/lin3"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:background="@drawable/shape">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Other Details"
android:gravity="center"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="E-Mail :"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/email"
android:singleLine="true"
android:imeOptions="actionDone"
android:layout_marginLeft="5dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date of Birth :"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/dob"
android:focusable="false"
android:imeOptions="actionNone"
android:layout_marginLeft="5dp"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lin5"
android:layout_below="@id/lin4"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:background="@drawable/shape">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Other Details"
android:gravity="center"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="E-Mail :"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/email_dum"
android:singleLine="true"
android:imeOptions="actionDone"
android:layout_marginLeft="5dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date of Birth :"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/dob_dum"
android:focusable="false"
android:imeOptions="actionNone"
android:layout_marginLeft="5dp"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lin6"
android:layout_below="@id/lin5"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:background="@drawable/shape">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Other Details"
android:gravity="center"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="E-Mail :"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/email_dum1"
android:singleLine="true"
android:imeOptions="actionDone"
android:layout_marginLeft="5dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date of Birth :"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/dob_dum1"
android:focusable="false"
android:imeOptions="actionNone"
android:layout_marginLeft="5dp"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@id/lin6"
android:gravity="center">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
android:id="@+id/submit"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/clear"
android:text="Clear"
android:layout_marginLeft="5dp"/>
</LinearLayout>
</RelativeLayout>
</ScrollView>
メインActivity_code: -
public class MainActivity extends AppCompatActivity {
EditText first_name,last_name,phone_no,city,state,country,zip_code,full_address,email,dob;
Button submit,clear;
private int year;
private int month;
private int day;
private Calendar cal;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
first_name=(EditText)findViewById(R.id.fname);
last_name=(EditText)findViewById(R.id.lname);
phone_no=(EditText)findViewById(R.id.pno);
city=(EditText)findViewById(R.id.city);
state=(EditText)findViewById(R.id.state);
zip_code=(EditText)findViewById(R.id.zipcode);
country=(EditText)findViewById(R.id.country);
full_address=(EditText)findViewById(R.id.address);
email=(EditText)findViewById(R.id.email);
dob=(EditText)findViewById(R.id.dob);
submit=(Button) findViewById(R.id.submit);
clear=(Button) findViewById(R.id.clear);
cal = Calendar.getInstance();
day = cal.get(Calendar.DAY_OF_MONTH);
month = cal.get(Calendar.MONTH);
year = cal.get(Calendar.YEAR);
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(MainActivity.this,result.class);
Bundle bundle=new Bundle();
bundle.putString("First_Name",first_name.getText().toString());
bundle.putString("Last_Name",last_name.getText().toString());
bundle.putString("Phone_No",phone_no.getText().toString());
bundle.putString("City",city.getText().toString());
bundle.putString("State",state.getText().toString());
bundle.putString("Country",country.getText().toString());
bundle.putString("Zip_Code",zip_code.getText().toString());
bundle.putString("Full_Address",full_address.getText().toString());
bundle.putString("Email",email.getText().toString());
bundle.putString("DOb",dob.getText().toString());
intent.putExtras(bundle);
startActivity(intent);
}
});
clear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
first_name.setText("");
last_name.setText("");
phone_no.setText("");
city.setText("");
state.setText("");
country.setText("");
zip_code.setText("");
full_address.setText("");
email.setText("");
dob.setText("");
}
});
dob.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DateDialog();
}
});
full_address.setOnTouchListener(new EditText.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
// Disallow ScrollView to intercept touch events.
v.getParent().requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
// Allow ScrollView to intercept touch events.
v.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
// Handle ListView touch events.
v.onTouchEvent(event);
return true;
}
});
}
private void DateDialog() {
DatePickerDialog.OnDateSetListener listener=new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth)
{
dob.setText(dayOfMonth+"/"+monthOfYear+"/"+year);
}};
DatePickerDialog dpDialog=new DatePickerDialog(this, listener, year, month, day);
dpDialog.show();
}
}
uは、このコードを確認することができます。
ありがとうございました。
問題は、レイアウトの親ではありません15エディットテキストのようなより多くの行を入力しview.ifスクロールでは、ユーザーには表示されません。レイアウトの上にスクロールされるためです。 – YBDevi