我有这个包含scrollview的布局,其中我有一个具有EditText视图的部分,但不知怎的,我无法专注于它们并在其中写入一些文本。任何人都可以帮助我并告诉我如何解决这个问题?
这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/details_scroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ebe6df" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="500dp"
android:layout_weight="1"
android:orientation="horizontal" >
<ImageView
android:id="@+id/details_image"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="@android:color/white"
android:contentDescription="@string/app_name"
android:padding="10dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="@android:color/white"
android:orientation="vertical"
android:padding="10dp" >
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/white" >
</android.support.v4.view.ViewPager>
<com.viewpagerindicator.CirclePageIndicator
android:id="@+id/indicator"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:background="@android:color/white"
android:padding="10dip"
app:fillColor="#e91a34"
app:pageColor="#cccccc"
app:strokeColor="#e91a34" />
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="@android:color/white"
android:padding="10dp" >
<TextView
android:id="@+id/details_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginBottom="5dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/details_title"
android:layout_margin="5dp"
android:background="#f4f2ee"
android:orientation="horizontal" />
<Button
android:id="@+id/details_share"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_below="@+id/linearLayout1"
android:background="@drawable/share" />
<ToggleButton
android:id="@+id/details_favorite"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignBottom="@+id/details_share"
android:layout_alignTop="@+id/details_share"
android:layout_toLeftOf="@+id/details_share"
android:background="@drawable/favorite_tgl"
android:textOff=""
android:textOn="" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/details_title"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/details_favorite"
android:gravity="bottom"
android:orientation="horizontal"
android:weightSum="100" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="25"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:src="@drawable/clock" />
<TextView
android:id="@+id/details_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="25"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:src="@drawable/female" />
<TextView
android:id="@+id/details_persons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="25"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:src="@drawable/gril" />
<TextView
android:id="@+id/details_calories"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="25"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:src="@drawable/gym" />
<TextView
android:id="@+id/details_gym"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:baselineAligned="false"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="1"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:orientation="horizontal"
android:padding="10dp" >
<TextView
android:id="@+id/textView111"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/ingredients"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:id="@+id/linearLayout5"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="@id/textView111"
android:layout_margin="5dp"
android:background="@drawable/intrerupt_line"
android:orientation="horizontal" />
<TextView
android:id="@+id/details_ingredients"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/linearLayout5"
android:layout_margin="5dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@android:color/white"
android:orientation="horizontal"
android:padding="10dp" >
<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="5dp"
android:text="@string/need_help_"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<TextView
android:id="@+id/textView22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView11"
android:layout_marginBottom="5dp"
android:text="@string/schedule_with_our_experts_"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView22"
android:layout_below="@+id/textView22"
android:layout_margin="5dp"
android:background="@drawable/gray_rounded_corners"
android:orientation="horizontal"
android:padding="1dp" >
<EditText
android:id="@+id/details_name"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/rounded_corners"
android:hint="@string/name"
android:inputType="textPersonName"
android:padding="10dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/subject"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/name"
android:layout_margin="5dp"
android:background="@drawable/gray_rounded_corners"
android:orientation="horizontal"
android:padding="1dp" >
<EditText
android:id="@+id/details_subject"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/rounded_corners"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="@string/subject"
android:inputType="textEmailSubject"
android:padding="10dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/subject"
android:layout_margin="5dp"
android:background="@drawable/gray_rounded_corners"
android:orientation="horizontal"
android:padding="1dp" >
<EditText
android:id="@+id/details_phone_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/rounded_corners"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="@string/phone_number"
android:inputType="phone"
android:padding="10dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/phone"
android:layout_margin="5dp"
android:background="@drawable/gray_rounded_corners"
android:orientation="horizontal"
android:padding="1dp" >
<EditText
android:id="@+id/details_time_of_day"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/rounded_corners"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="@string/time_of_day"
android:inputType="time"
android:padding="10dp" />
</LinearLayout>
<Button
android:id="@+id/details_schedule"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_below="@id/time"
android:layout_margin="5dp"
android:background="@drawable/red_button"
android:text="@string/make_apointment"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/white" />
</RelativeLayout>
</LinearLayout>
<!-- beginh here -->
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="@android:color/white"
android:orientation="horizontal"
android:padding="10dp" >
<TextView
android:id="@+id/textViewsteps"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/steps"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/details_steps"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/linearLayout4"
android:layout_margin="5dp" />
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="@id/textViewsteps"
android:layout_margin="5dp"
android:background="@drawable/intrerupt_line"
android:orientation="horizontal" />
</RelativeLayout>
<!-- end here -->
</LinearLayout>
</LinearLayout>
</ScrollView>
我也使用了这个,但它既没有工作:
public class NonFocusingScrollView extends ScrollView {
public NonFocusingScrollView(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
}
public NonFocusingScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public NonFocusingScrollView(Context context) {
super(context);
}
@Override
public ArrayList<View> getFocusables(int direction) {
return new ArrayList<View>();
}
}