我真的很想找到垂直和水平Scrollview的解决方案.
我读到框架中没有任何实现此功能的视图/布局,但我需要这样的东西:
我需要在其他内部定义布局,子布局必须实现滚动垂直/水平移动.
最初实现了一个逐像素移动布局的代码,但我认为这不是正确的方法.我尝试使用ScrollView和Horizontal ScrollView,但没有任何工作像我想要的那样,因为它只实现垂直或水平滚动.
Canvas不是我的解决方案,因为我需要在某些子元素中附加侦听器.
我能做什么?
我知道谷歌的人已经要求我们不要将Scrollable视图放在另一个Scrollable视图中,但他们是否有任何官方声明指示我们不要这样做?
我有一个scrollview布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:fadingEdge="none"
android:overScrollMode="never"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="100"
android:background="@color/antiquewhite">
<LinearLayout
android:id="@+id/top_layou"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="15"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginTop="25dp"
android:background="@color/bisque">
<TextView
android:id="@+id/title_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dp"
android:layout_marginTop="15dp"
android:text="@string/user_information_text"
android:textSize="26dp"
android:textStyle="bold"
android:textColor="@color/black" />
<TextView
android:id="@+id/subtitle_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dp"
android:layout_marginTop="5dp"
android:text="@string/user_information_subtitle_text"
android:textSize="20dp"
android:textStyle="bold"
android:textColor="@color/black"/>
</LinearLayout>
<LinearLayout
android:id="@+id/body_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="85"
android:orientation="horizontal"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:weightSum="100"
>
<LinearLayout
android:id="@+id/left_part"
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="50"
android:weightSum="100"
android:background="@color/antiquewhiter">
<TextView
android:id="@+id/first_name_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dp"
android:layout_marginTop="30dp"
android:text="@string/first_name_text"
style="@style/bold_text18"
/>
<LinearLayout
android:id="@+id/first_name_edit_layout"
android:layout_width="match_parent" …Run Code Online (Sandbox Code Playgroud) 我有一个同时包含 ScrollView 和 HorizontalScrollView 的布局文件。并且能够在水平方向或垂直方向滚动。可以对角滚动吗?
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Customview..../>
</HorizontalScrollView>
</ScrollView>
Run Code Online (Sandbox Code Playgroud) android scrollview custom-scrolling horizontalscrollview android-layout
我们如何ScrollView纵向和横向设置?我尝试了下面的代码,但它没有用.
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/red"
android:scrollbarFadeDuration="1000"
android:scrollbarSize="12dip" >
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:collapseColumns="2"
android:stretchColumns="1" >
</TableLayout>
</HorizontalScrollView>
<ScrollView >
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
这是我的所有代码:http://pastebin.com/ysRhLMyt
当前屏幕:

我想总是显示滚动条.
我有一个在ScrollView中的TableLayout,所以我得到垂直滚动.但是当列超出屏幕时,我也想要水平滚动.
我怎样才能做到这一点?请帮忙.
谢谢,法哈