[英]How to change specific XML attribute of custom UI element programmatically in android
I am using a custom UI component in my project which has it's own few attributes.我在我的项目中使用了一个自定义 UI 组件,它有自己的几个属性。 I want to change a specific one using a function when it is clicked.我想在单击时使用 function 更改特定的。 I don't know how to access it though, I am fairly new in this department.我不知道如何访问它,我是这个部门的新手。
<com.chinodev.androidneomorphframelayout.NeomorphFrameLayout
android:id="@+id/btnsystem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
app:neomorph_background_color="@color/appBackground"
app:neomorph_corner_radius="10dp"
app:neomorph_elevation="4dp"
app:neomorph_highlight_color="#ffffff"
app:neomorph_shadow_color="#CDCDCD"
app:neomorph_view_type="rectangular">
here say I want to change the app:neomorph_elevation
using onclick function how can I do that?这里说我想使用 onclick function 更改app:neomorph_elevation
neomorph_elevation 我该怎么做?
In NeomorphFrameLayout
you can add a public function changeElevation ex在NeomorphFrameLayout
,您可以添加公共 function changeElevation ex
fun changeElevation(elevation :Float){
neomorph_elevation = elevation
}
and can use in onClickListener like并且可以在 onClickListener 中使用
btnsystem.changeElevation(5f)
As they specified in library that,正如他们在图书馆中指定的那样,
Attributes: neomorph_clickable option set it to true and onClick trigger a function from xml or from setOnClickListener whichever you prefer...属性:neomorph_clickable 选项将其设置为 true 和 onClick 触发 function 从 xml 或从 setOnClickListener 哪个你喜欢...
https://github.com/4inodev/Neomorphic-FrameLayout-Android https://github.com/4inodev/Neomorphic-FrameLayout-Android
History of Android repository XML Android 存储库 XML 的历史
Used by sdkmanager
command.由sdkmanager
命令使用。
Used by android
command, which is deprecated and unavailable in the latest Android SDK Tools (since r25.3.0)由android
命令使用,在最新的 Android SDK 工具(自 r25.3.0 起)中已弃用且不可用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.