Java MPAndroidChart内部水平滚动视图
(此问题也适用于ScrollView) 我需要在Java MPAndroidChart内部水平滚动视图,java,android,charts,scrollview,mpandroidchart,Java,Android,Charts,Scrollview,Mpandroidchart,(此问题也适用于ScrollView) 我需要在水平滚动视图中放置一个折线图。我不希望在图表中滚动(这意味着图表本身会呈现滚动,在多次TEST之后,它会非常滞后),除非它是最后一个解决方案 图书馆在建 基于此,它不应该是复杂的 不幸的是,我似乎无法达到预期的结果 这是我的XML代码: <HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_widt
水平滚动视图
中放置一个折线图
。我不希望在图表中滚动(这意味着图表本身会呈现滚动,在多次TEST之后,它会非常滞后),除非它是最后一个解决方案
图书馆在建
基于此,它不应该是复杂的
不幸的是,我似乎无法达到预期的结果
这是我的XML代码:
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.github.mikephil.charting.charts.LineChart
android:layout_width="2000dp"
android:layout_height="match_parent"
android:fillViewport="true"
android:id="@+id/chart"/>
</HorizontalScrollView>
没什么特别的
Android Studio internal designer显示了一个缩小的图表,我的手机也显示了
怎么了
谢谢你的帮助 使用线性布局作为折线图的容器:
<HorizontalScrollView
android:id="@+id/hsvChart"
android:layout_width="800dp"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.github.mikephil.charting.charts.LineChart
android:id="@+id/chart"
android:layout_width="600dp"
android:layout_height="match_parent"
android:layout_marginBottom="3dp"
android:layout_marginTop="3dp" />
</LinearLayout>
</HorizontalScrollView>
通过设置水平视图的宽度匹配父级和图表的自定义宽度(请参见下面的代码),这将防止图表缩小
你是否有解决方案?@Shadow我仍然没有解决方案。图表缩小了。你找到解决办法了吗?如果我不想使用固定宽度怎么办?因为在我的应用程序中,x轴上的标签有时很小,并且可能会更改为40到50个字符或更多。@adelturk您可以通过编程方式计算屏幕宽度,并将其保留为java中的最大宽度file@RaviYadavthnx希望有人能理解你的评论,这可能会帮助他们,因为这已经是一个很长的时间了:P
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="400dp"
android:fillViewport="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<com.github.mikephil.charting.charts.BarChart
android:id="@+id/bar_chart"
android:layout_width="800dp"
android:layout_height="match_parent"
android:background="@color/colorWhite"
android:padding="10dp" />
</LinearLayout>
</HorizontalScrollView>