【问题标题】:Putting checkboxes below an AChartEngine graph将复选框放在 AChartEngine 图下方
【发布时间】:2014-07-14 13:29:03
【问题描述】:

我想在图表下方添加一些复选框,但不知道该怎么做。就目前而言,该图表正在占据整个屏幕,所以我想我应该先把它变小,我也不知道该怎么做。 这是我尝试显示复选框时的当前样子:

另外,这是我当前用于布局的 xml 代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".ViewGraphActivity" >

<LinearLayout
    android:id="@+id/chart_container"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/tv_title"
    android:orientation="horizontal" >
</LinearLayout>

<LinearLayout
    android:id="@+id/checkbox_container"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_centerVertical="true"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/checkBoxTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="View which lines:" />

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="103dp"
        android:orientation="horizontal" >

        <CheckBox
            android:id="@+id/checkBox1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Distance" />

        <CheckBox
            android:id="@+id/checkBox2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="28dp"
            android:text="Time" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="271dp"
        android:layout_height="34dp"
        android:layout_marginTop="34dp"
        android:orientation="horizontal" >

        <CheckBox
            android:id="@+id/checkBox3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Velocity" />

        <CheckBox
            android:id="@+id/checkBox4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="28dp"
            android:text="Calories" />
    </LinearLayout>
</LinearLayout>

【问题讨论】:

    标签: android android-layout checkbox achartengine android-checkbox


    【解决方案1】:

    为您的checkbox_container:

    android:layout_centerVertical="true" => android:layout_alignParentBottom="true"
    

    【讨论】:

    • 感谢您的帮助。我假设它起作用了,因为复选框不再在图表上,但是它们消失了,我仍然不知道如何使图表更小以查看是否可以看到复选框... =/跨度>
    • @theJuls 这也很简单,您只需在 'android:id="@+id/chart_container"' 元素中设置 android:layout_above="@+id/checkbox_container"。
    • 感谢它的工作!事实证明我在做相反的事情:将 android:layout_belo="@+id/chart_container" 放在 checkbox_container 上。不知道为什么这个比另一个更有效。不管怎样,它现在工作得很好:)
    • 这可能是因为wrap_content 对图表的行为使它们占用了所有可用空间,从而迫使复选框离开屏幕。由于复选框具有相当小的、可预测的高度,因此您现在告诉图表以确保它们考虑复选框所需的任何高度,反之亦然,这就是它起作用的原因。
    猜你喜欢
    • 1970-01-01
    • 2021-06-07
    • 2014-09-20
    • 1970-01-01
    • 2011-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    相关资源
    最近更新 更多