【问题标题】:how to know which parameters to define in androidPlot xml layout file如何知道在 androidPlot xml 布局文件中定义哪些参数
【发布时间】:2026-01-24 02:25:01
【问题描述】:

我正在浏览 androidPlot 的快速入门。 http://androidplot.com/docs/quickstart/ 在示例 simple_xy_plot_example.xml 布局文件中定义了诸如

之类的参数
androidPlot.titleWidget.labelPaint.textSize="@dimen/title_font_size"
            androidPlot.domainLabelWidget.labelPaint.textSize="@dimen/domain_label_font_size"
            androidPlot.rangeLabelWidget.labelPaint.textSize="@dimen/range_label_font_size"
            androidPlot.graphWidget.marginTop="20dp"
            androidPlot.graphWidget.marginLeft="15dp"
            androidPlot.graphWidget.marginBottom="25dp"

但是这些参数是在哪里定义的呢?我的意思是我怎么知道使用 titleWidget.labelPaint.textSize 来定义 textSize?

【问题讨论】:

  • 向下滚动一点,您会在res/values/dimens.xml 部分找到它。
  • 我的意思是如何定义层次结构路径,例如ndroidPlot.graphWidget.marginLeft
  • 抱歉造成误会。您可以找到 XYPlot 的文档here。你可以在那里找到它的所有成员。您看不到它的属性,但您会发现它的所有 getter 和 setter。只需删除 get/set 即可获得您的财产。

标签: android xml android-layout androidplot


【解决方案1】:

像这样在res/values/dimens.xml中定义这些变量

<resources>
    <!-- Default screen margins, per the Android Design guidelines. -->
    <dimen name="activity_horizontal_margin">16dp</dimen>
    <dimen name="activity_vertical_margin">16dp</dimen>
    <dimen name="title_font_size">16dp</dimen>
    <dimen name="domain_label_font_size">12dp</dimen>
    <dimen name="range_label_font_size">12dp</dimen>
    <dimen name="range_tick_label_font_size">12dp</dimen>
    <dimen name="domain_tick_label_font_size">12dp</dimen>
    <dimen name="legend_text_font_size">12dp</dimen>
</resources>

domain_label_font_size 是您要定义的值。

【讨论】:

    最近更新 更多