简体   繁体   English

从另一个xml元素引用XML属性

[英]Referencing an XML attribute from another xml element

I'm trying out new things (well, im also new to xml and android). 我正在尝试新事物(嗯,对于xml和android来说,我也是新事物)。 This thing came up to my mind during my brain storming. 这件事在我头脑风暴期间浮现在脑海。 Is it possible to reference an XML element attribute for a value of an element? 是否可以为元素的值引用XML元素属性? (sorry the english isn't quite well) (对不起,英语不太好)

idea : 想法:

<SeekBar
    android:id="@+id/seekBar1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/textView1"
    android:layout_below="@+id/textView3"
    android:layout_marginLeft="15dp"
    android:layout_marginTop="12dp"
    android:layout_toRightOf="@+id/textView4"
    android:max="9"
    android:progress="0" />

<TextView
    android:id="@+id/textView7"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/textView5"
    android:layout_toRightOf="@+id/seekBar1"
    **android:text="@id/seekBar1/progress"**
    android:textAppearance="?android:attr/textAppearanceSmall" />

the highlighted part. 突出显示的部分。 Thanks for reading and for possible answers 感谢您的阅读和可能的答案

Simple answer: No , unfortunately it's not. 简单的回答: ,不幸的是,不是。

And even if it worked, there were two additional issues: 即使有效,仍然存在两个其他问题:

  • It seems you would expect the TextView to be updated when the SeekBar progresses, which would not work even if the reference would work. 似乎您希望在SeekBar进行时更新TextView ,即使引用有效,该操作也不起作用。

  • The system had to automatically convert the progress (a float) to a String. 系统必须自动将进度(浮点数)转换为String。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM