将按钮和androidplot添加到滚动视图 [英] Adding buttons and androidplot to a scrollview

查看:54
本文介绍了将按钮和androidplot添加到滚动视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法将按钮和androidplot一起放到scrollview中,这样我就可以向下滚动,越过androidplot来查看按钮.我正在使用androidplot 0.9.8.

I can't seem to get buttons and androidplot together into a scrollview such that I can scroll down, past the androidplot to see the buttons. I am using androidplot 0.9.8.

这是我的xml文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ap="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="example.example.MainActivity">
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/plotLayout">
            <com.androidplot.xy.XYPlot
                    android:id="@+id/plot"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    ap:Label="test"
                    ap:domainLabel="test"
                    ap:rangeLabel="test"
                    ap:renderMode="use_main_thread"/>
            <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:layout_below="@id/plot">
                    <Button
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:text="test"/>
                    <Button
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:text="test"/>
                    </LinearLayout>
        </RelativeLayout>
</ScrollView>

但是,当我为androidplot指定某个高度时(例如android:layout_height ="600dp"而不是android:layout_height ="match_parent"),它可以正常滚动.为什么使用match_parent阻止其滚动?

It seems however that when I specify a certain height for androidplot (e.g. android:layout_height="600dp" instead of android:layout_height="match_parent") it scrolls fine. Why is it that using match_parent prevents it from scrolling?

推荐答案

我通过以编程方式为绘图设置手动大小来设法破解了它.您可以获取图的布局参数,然后手动更改高度.我认为身高似乎有问题吗?

I managed to hack it a little by programmatically setting a manual size to the plot. You can get the layout parameters of the plot and then manually change the height. I think there seems to be some sort of issue with height?

XYPlot plot = (XYPlot) findViewById(R.id.plot);
LayoutParams lp = plot.getLayoutParams();
lp.height = 1710; // You can set it to whatever height you require it to be, 1710 is just an example
plot.setLayoutParams(lp);

这篇关于将按钮和androidplot添加到滚动视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆