水平滚动视图内的滚动视图无法正常工作
希望我们玩得开心。伙计,我遇到了一个小问题。当我将垂直滚动视图放在水平滚动视图内时,垂直滚动视图无法正常工作。(我也尝试反之亦然,将水平滚动视图放在垂直内。)
当我尝试滚动布局只允许我向一个方向滚动,而不是同时向两个方向滚动。 我认为这是android真正的问题。
请提供任何解决方案。 问候
<?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:weightSum="1" >
<LinearLayout
android:id="@+id/linearLayout21"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:background="@drawable/top_bar_bg" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="1dip"
android:layout_marginTop="1dip"
android:text=" Image card"
android:textAppearance="?android:attr/textAppearanceLarge" >
</TextView>
</LinearLayout>
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Description"
android:textSize="20sp" >
</TextView>
<EditText
android:id="@+id/IMAGEVIEW_TEXTVEIW"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_below="@+id/textView1"
android:clickable="false"
android:cursorVisible="false"
android:focusable="false"
android:gravity="top" >
</EditText>
</RelativeLayout>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Image"
android:textSize="20sp" >
</TextView>
</LinearLayout>
<RelativeLayout
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical|fill_horizontal" >
<RelativeLayout
android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_margin="5dip" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center" >
<RelativeLayout
android:id="@+id/relativeLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true" >
<ImageView
android:id="@+id/IMAGE_VIEW"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/diamond" >
</ImageView>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
</HorizontalScrollView>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
Hope we have good time.dude i m stuck in a little problem .when i place vertical scroll view inside horizontal scroll view then vertical scrollview not works properly.(i tried vice verse too by placing horizontal scroll view inside vertical.)
when i try to scroll the layout just allow me to scroll in one direction not in both simultaneously.
i think this is android genuine problem.
kindly provide any solution .
Regards
<?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:weightSum="1" >
<LinearLayout
android:id="@+id/linearLayout21"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:background="@drawable/top_bar_bg" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="1dip"
android:layout_marginTop="1dip"
android:text=" Image card"
android:textAppearance="?android:attr/textAppearanceLarge" >
</TextView>
</LinearLayout>
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Description"
android:textSize="20sp" >
</TextView>
<EditText
android:id="@+id/IMAGEVIEW_TEXTVEIW"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_below="@+id/textView1"
android:clickable="false"
android:cursorVisible="false"
android:focusable="false"
android:gravity="top" >
</EditText>
</RelativeLayout>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Image"
android:textSize="20sp" >
</TextView>
</LinearLayout>
<RelativeLayout
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical|fill_horizontal" >
<RelativeLayout
android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_margin="5dip" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center" >
<RelativeLayout
android:id="@+id/relativeLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true" >
<ImageView
android:id="@+id/IMAGE_VIEW"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/diamond" >
</ImageView>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
</HorizontalScrollView>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
有比创建自定义视图更简单的解决方案:
布局:
代码(onCreate/onCreateView):
您可以更改滚动视图的顺序。只需更改它们在布局和代码中的顺序即可。显然,您可以放置想要双向滚动的布局/视图,而不是 WatereverViewYouWant。
There is much more simpler solution than creating a custom view:
Layout:
Code (onCreate/onCreateView):
You can change the order of the scrollviews. Just change their order in layout and in the code. And obviously instead of WateverViewYouWant you put the layout/views you want to scroll both directions.
请参阅下面的 xml。这对我有用。希望对您也有用。
See Below xml.This works for me.Hope will work for you too.
我不确定你能以这种方式实现你想要的目标。至少根据我读到的内容不是这样。
然而,这是一个制作自定义滚动视图的人的博客,可能适合您的需求。
http://blog.gorges.us/2010/06/android-二维滚动视图/
I'm not sure you can achieve what you're trying to that way. Atleast not according to what I've read.
However, here is a blog by a guy who made a custom scrollview, that might fit your needs.
http://blog.gorges.us/2010/06/android-two-dimensional-scrollview/
如果您要在
HorizontalScrollView
内的RecyclerView
中显示项目,只需添加一行代码即可使其变得简单:如果您有多个
HorizontalScrollView
对于ScrollView
,您可以对HorizontalScrollView
中的每个RecyclerView
使用相同的代码,该代码位于滚动视图
。If you are using displaying items in
RecyclerView
inside theHorizontalScrollView
, just make it simple by adding a line of code:If you have multiple
HorizontalScrollView
inside theScrollView
you can can use the same above code for eachRecyclerView
inHorizontalScrollView
which is inside theScrollview
.