如何在Android中滚动滚动滚动视图使其成为顶部的子视图
我的“活动”视图中有一个滚动视图,在此布局中,我将通过在循环中膨胀另一个布局(膨胀的布局数量随时间变化)在“ucontent”和“pcontent”中添加动态内容。我需要滚动scrollview sv,以便当我单击“titlep”时,带有“titlep”的倾斜显示在顶部如何在Android中滚动滚动滚动视图使其成为顶部的子视图,android,android-layout,scroll,Android,Android Layout,Scroll,我的“活动”视图中有一个滚动视图,在此布局中,我将通过在循环中膨胀另一个布局(膨胀的布局数量随时间变化)在“ucontent”和“pcontent”中添加动态内容。我需要滚动scrollview sv,以便当我单击“titlep”时,带有“titlep”的倾斜显示在顶部 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/sv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#232323"
android:scrollbars="none" >
<LinearLayout
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#232323"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/titleu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#D84A49"
android:orientation="horizontal"
android:paddingBottom="7dp"
android:paddingTop="7dp" >
<ImageView
android:id="@+id/toggleu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="2dp"
android:src="@drawable/toggleu" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="title1....."
android:textColor="#ffffff" />
</LinearLayout>
<LinearLayout
android:id="@+id/ucontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="@+id/titlep"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="0dp"
android:layout_marginTop="5dp"
android:background="#D84A49"
android:orientation="horizontal"
android:paddingBottom="7dp"
android:paddingTop="7dp" >
<ImageView
android:id="@+id/togglep"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="2dp"
android:src="@drawable/toggleu" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight=".1"
android:text="title2...."
android:textColor="#ffffff" />
</LinearLayout>
<LinearLayout
android:id="@+id/pcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
如何在代码或xml中实现这一点?请看一下:
使用isFocusable(true)
在onClick上使用
requestFocus()
可以提供当前屏幕的屏幕截图吗?无论如何,尝试添加我创建了滚动布局,它的滚动很好,但我的问题是如何在id为'titlep'的linearlayout的onclick事件上以编程方式滚动,以便'titlep'将出现在屏幕的to中啊,好的,现在我明白了。thanx为线索,isFocusable(true)方法不存在,我使用了setFocusable(true)来设置焦点.isFocusable()用于检查是否可聚焦