我如何防止自动关注创建滚动视图的活动

时间:2015-06-13 07:09:10

标签: android

当创建活动时,焦点是滚动视图编辑文本框上的自动传输,但我想停止此过程,我想当用户触摸编辑文本框然后焦点转移到滚动视图.Pleas帮助我。

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
    android:background="@drawable/new_background"
    android:descendantFocusability="afterDescendants">
    <LinearLayout
        android:id="@+id/ll_Login_ContentHolder"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/new_background"
        android:gravity="center"
        android:orientation="vertical"
        android:paddingBottom="@dimen/padding_top_bottom"
        android:paddingLeft="@dimen/padding_left"
        android:paddingRight="@dimen/padding_right"
        android:paddingTop="@dimen/padding_top_bottom"
        android:weightSum="1" >

    <LinearLayout
            android:id="@+id/ll_Login_Content"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            android:background="@android:color/transparent"
            android:gravity="center_horizontal"
            android:orientation="vertical"
            android:weightSum="1" >


            <ImageView
                android:id="@+id/imgview_login_cabmapsLogo"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight=".7"
                android:scaleType="centerInside"
                android:src="@drawable/new_cabmaps_logo" />

<ScrollView
    android:id="@+id/scrollview"
    android:layout_width="match_parent"
    android:layout_height="200dip" >

            <LinearLayout
                android:id="@+id/ll_Login_Content1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight=".3"
                android:layout_marginTop="@dimen/Login_VerticalMargin"  

                android:orientation="vertical" >

                <EditText
                    android:id="@+id/Edtxt_Login_UserNm"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/Edtxt_height"
                    android:background="@color/new_EdtxtBg"
                    android:drawableLeft="@drawable/new_email"
                     android:drawablePadding="@dimen/drawable_padding"
                    android:cursorVisible="true"
                    android:gravity="left|center_vertical"
                    android:hint="@string/UserNm"
                    android:imeOptions="actionNext"
                    android:inputType="textPersonName|textNoSuggestions"
                    android:paddingLeft="@dimen/view_padding_left"
                    android:textSize="@dimen/textsize" />

                <EditText
                    android:id="@+id/Edtxt_Login_Password"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/Edtxt_height"
                    android:layout_marginTop="@dimen/Login_VerticalMargin"
                    android:background="@color/new_EdtxtBg"
                    android:drawableLeft="@drawable/new_password"
                    android:drawablePadding="@dimen/drawable_padding"
                    android:gravity="left|center_vertical"
                    android:hint="@string/Password"
                    android:imeOptions="actionDone"
                    android:inputType="textPassword"
                    android:paddingLeft="@dimen/view_padding_left"
                    android:textSize="@dimen/textsize" />

                <LinearLayout
                    android:id="@+id/ll_login"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"

                    android:layout_marginTop="@dimen/Login_VerticalMargin"
                    android:gravity="center"
                    android:orientation="horizontal"
                    android:weightSum="1" >
                     <Button
                        android:id="@+id/btn_Login_NewUser"
                        android:layout_width="match_parent"
                        android:layout_height="@dimen/btn_height"

                        android:layout_weight=".50"
                        android:background="@color/new_OrangeBtnColor"
                        android:text="SIGN UP"
                        android:textColor="@color/TextColor"
                        android:textSize="@dimen/btntextsize" />

                    <Button
                        android:id="@+id/btn_Login_login"
                        android:layout_width="match_parent"
                        android:layout_height="@dimen/btn_height"
                        android:layout_marginRight="5dp"
                        android:layout_weight=".50"
                         android:layout_marginLeft="5dp"
                        android:background="@color/new_OrangeBtnColor"
                        android:text="LOGIN"
                        android:textColor="@color/TextColor"
                        android:textSize="@dimen/btntextsize" />


                </LinearLayout>
                    <TextView 
                    android:id="@+id/tv_OR"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/new_or"
                    android:layout_marginTop="@dimen/Login_VerticalMargin"
                   />
            </LinearLayout>     
            </ScrollView>
            <LinearLayout
                android:id="@+id/ll_Login_Content2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/Login_VerticalMargin"
                android:orientation="horizontal"

                 >

                <Button
                    android:id="@+id/loginViaFB"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/btn_height"
                    android:background="@drawable/new_fb"
                    android:onClick="onSocialMediaLoginClick"
                    android:tag="1"  
                    android:layout_weight=".50"              
                 />

                <Button
                    android:id="@+id/loginViaTwitter"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/btn_height"
                    android:layout_marginLeft="10dp"
                    android:background="@drawable/new_twitter"
                    android:onClick="onSocialMediaLoginClick"
                    android:tag="2"
                     android:layout_weight=".50"
                    />
            </LinearLayout>
                <Button
                    android:id="@+id/btnForgotPassword"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="15dp"
                    android:background="@android:color/transparent"
                    android:text="@string/ForgotPassword"
                    android:layout_gravity="center_horizontal"
                    android:textColor="@android:color/background_light"
                    android:autoLink="all" />


            </LinearLayout>



    </LinearLayout>

</LinearLayout> 

1 个答案:

答案 0 :(得分:0)

 <LinearLayout
            android:id="@+id/ll_Login_Content1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight=".3"
            android:layout_marginTop="@dimen/Login_VerticalMargin"  

            android:orientation="vertical" >

你可以在上面的布局android:focusableInTouchMode =“true”

中添加这一行