小编Smi*_*ith的帖子

Fragment中onCreateView和onViewCreated之间的区别

这两种方法之间的本质区别是什么?当我创建TextView时,我应该使用其中一个来提高性能吗?

编辑:有什么区别

onCreateView() {
  root = some view
  View v = new View(some context);
  root.add(v);
  return root;
}


onViewCreated() {
  View v = new View(some context);
  getView().add(v);
}
Run Code Online (Sandbox Code Playgroud)

android android-layout android-fragments

99
推荐指数
7
解决办法
7万
查看次数

在Horizo​​ntalScrollView上聚焦EditText会导致ScrollView隐藏EditText

我有一个水平滚动视图占据了屏幕的右半部分.在它上面,我有一个EditText.当我选择EditText来编辑文本时,Horizo​​ntalScrollView会向右滚动.我猜它正在尝试将EditText放在最左边的位置.无论如何,由于Horizo​​ntalScrollView占据了屏幕的右侧,通过这样做,我再也看不到EditText,因为它现在被我放在屏幕左侧的内容所掩盖.当我专注于布局内的某些内容时,如何防止Horizo​​ntalScrollView自动滚动?

谢谢.非常感激.

HALP

编辑:发布代码.我实际上是基于生成的信息创建我的EditText,所以这不是它实际上的样子,但它应该捕获ideai.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <View
        android:layout_leftOf="@+id/Anchor"/>


    <View
        android:id="@+id/Anchor"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_centerHorizontal="true"
        android:background="#000" />

    <ScrollView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_rightOf="@+id/Anchor"
            android:fillViewport="true" >

            <HorizontalScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fillViewport="true" >

                <TableLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="10dp" >

                  <TableRow>
                     <EditText>

                     ABOVE is the view that is going to the left

                     MOre views which would cause Scrolling to the right

                  </TableRow>
                </TableLayout>

            </HorizontalScrollView>
        </ScrollView>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

android scroll horizontalscrollview android-edittext

2
推荐指数
1
解决办法
881
查看次数