当触摸GridView中的EditText时,水平滚动视图在屏幕末端自动滚动

时间:2019-02-08 02:50:03

标签: c# android xamarin android-edittext horizontalscrollview

我开始在android xamarin中进行编程,就是这种情况:

我有一个垂直滚动视图和一个水平滚动视图,在这两个视图中,当我在Android设备上进行测试时,我都有自己的gridview来制作一张表格来显示平均值结果,然后触摸屏幕上的EditText。 / p>

屏幕自动滚动到水平背景,从而失去对EditText的关注。

Before touch EditText

After touch EditText

代码:

        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        xmlns:android="http://schemas.android.com/apk/res/android">

<HorizontalScrollView
    android:id="@+id/HorizontalScrollView01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    >

    <GridLayout
        android:layout_height="match_parent"
        android:rowCount="14"
        android:columnCount="11"
        android:layout_width="match_parent" 
        android:descendantFocusability="beforeDescendants"
        android:focusable="true"
        android:focusableInTouchMode="true">
 >
        <TextView
            android:text="Ingresar 
        datos"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/textView0_1"
            android:layout_row="0"
            android:layout_column="0" />
        <Button
            android:layout_row="0"
            android:layout_column="2"
            android:text="Calcular"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/BotonCalcular"/>
        <Button
            android:layout_row="0"
            android:layout_column="4"
            android:text="Reiniciar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/BotonReiniciar"/>
        <Button
            android:layout_row="0"
            android:layout_column="6"
            android:text="Inicio"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/BotonHistorialTraducciones"
             />
        <Space
            android:layout_row="0"
            android:layout_column="1"
            android:layout_width="20dp"
            android:layout_height="20dp" />
        <Space
            android:layout_row="0"
            android:layout_column="3"
            android:layout_width="20dp"
            android:layout_height="20dp" />
        <Space
            android:layout_row="0"
            android:layout_column="5"
            android:layout_width="20dp"
            android:layout_height="20dp" />
        <Space
            android:layout_row="0"
            android:layout_column="7"
            android:layout_width="20dp"
            android:layout_height="20dp" />
        <Space
            android:layout_row="0"
            android:layout_column="9"
            android:layout_width="20dp"
            android:layout_height="20dp" />
        <Space
            android:layout_row="0"
            android:layout_column="1"
            android:layout_width="20dp"
            android:layout_height="20dp" />
        <TextView
            android:text="Semana"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/textView0_2"
            android:layout_row="1"
            android:layout_column="0" />
        <TextView
            android:text="Datos"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/textView0_2"
            android:layout_row="1"
            android:layout_column="2" />
        <TextView
            android:text="PM(3)"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/textView0_3"
            android:layout_row="1"
            android:layout_column="4" />
        <TextView
            android:text="Error"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/textView0_4"
            android:layout_row="1"
            android:layout_column="6" />
        <TextView
            android:text="Pm(6)"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/textView0_5"
            android:layout_row="1"
            android:layout_column="8" />
        <TextView
            android:text="Error"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/textView0_6"
            android:layout_row="1"
            android:layout_column="10" />
        <TextView
            android:text="1"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/textView2_0"
            android:layout_row="2"
            android:layout_column="0"
            android:textAlignment="center" />
        <TextView
            android:text="2"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/textView3_0"
            android:layout_row="3"
            android:layout_column="0"
            android:textAlignment="center" />
        <TextView
            android:text="3"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/textView4_0"
            android:layout_row="4"
            android:layout_column="0"
            android:textAlignment="center" />
        <TextView
            android:text="4"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/textView5_0"
            android:layout_row="5"
            android:layout_column="0"
            android:textAlignment="center" />
        <TextView
            android:text="5"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/textView6_0"
            android:layout_row="6"
            android:layout_column="0"
            android:textAlignment="center" />
        <TextView
            android:text="6"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/textView7_0"
            android:layout_row="7"
            android:layout_column="0"
            android:textAlignment="center" />
        <TextView
            android:text="7"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/textView8_0"
            android:layout_row="8"
            android:layout_column="0"
            android:textAlignment="center" />
        <TextView
            android:text="8"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/textView9_0"
            android:layout_row="9"
            android:layout_column="0"
            android:textAlignment="center" />
        <TextView
            android:text="9"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/textView10_0"
            android:layout_row="10"
            android:layout_column="0"
            android:textAlignment="center" />
        <TextView
            android:text="10"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/textView11_0"
            android:layout_row="11"
            android:layout_column="0"
            android:textAlignment="center" />
        <EditText
            android:text="1"
            android:inputType="number"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/Dato1"
            android:layout_row="2"
            android:layout_column="2"
            android:textAlignment="center"
         />
        <EditText
            android:text="2"
            android:inputType="number"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/Dato2"
            android:layout_row="3"
            android:layout_column="2"
            android:textAlignment="center"
            />
        <EditText
            android:text="3"
            android:inputType="number"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/Dato3"
            android:layout_row="4"
            android:layout_column="2"
            android:textAlignment="center" />
        <EditText
            android:text="4"
            android:inputType="number"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/Dato4"
            android:layout_row="5"
            android:layout_column="2"
            android:textAlignment="center" />
        <EditText
            android:text="5"
            android:inputType="number"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/Dato5"
            android:layout_row="6"
            android:layout_column="2"
            android:textAlignment="center" />
        <EditText
            android:text="6"
            android:inputType="number"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/Dato6"
            android:layout_row="7"
            android:layout_column="2"
            android:textAlignment="center" />
        <EditText
            android:text="7"
            android:inputType="number"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/Dato7"
            android:layout_row="8"
            android:layout_column="2"
            android:textAlignment="center" />
        <EditText
            android:text="8"
            android:inputType="number"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/Dato8"
            android:layout_row="9"
            android:layout_column="2"
            android:textAlignment="center" />
        <EditText
            android:text="9"
            android:inputType="number"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/Dato9"
            android:layout_row="10"
            android:layout_column="2"
            android:textAlignment="center" />
        <EditText
            android:text="10"
            android:inputType="number"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/Dato10"
            android:layout_row="11"
            android:layout_column="2"
            android:textAlignment="center" />
        <TextView
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/Promedio1"
            android:layout_row="5"
            android:layout_column="4"
            android:textAlignment="center" />
    </GridLayout>
</HorizontalScrollView>
</ScrollView>

created_date

亲切问候

0 个答案:

没有答案