【发布时间】:2021-01-22 21:29:53
【问题描述】:
我有一个 xml 文件,我想通过使用扩展 View 的类将其更改为组件。 我该怎么做??
java代码:
public class custom extends View {
public custom(Context context) {
super(context);
}
public custom(Context context , AttributeSet attrs) {
super(context , attrs);
}
}
这是我的 xml 代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.apd.ecryptfolders.custom">
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"/>
谢谢!
【问题讨论】:
标签: java android xml file custom-component