a layout to re-arrange child components via dragging
Plan A:Local source integration, the user can be customized to modify 1.The library folder copy to the project directory 2.Modify the project Settings. Under the gradle, add reliance on library module as follows:
include ':entry', ':Library'
3.Dependence on the introduction of the import module under the project, to sample module, for example, you need to modify the sample under the module of the build. Gra
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
implementation project(path: ':library')
testImplementation 'junit:junit:4.13'
ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
}
Plan B:Local har package integration.
1.Compile the project, will build the library folder directory generated har package copy to the project lib folder:
2.Add the following code in the entry of gradle
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
Plan C:Maven remote warehouse
build.gradle
file (not your module build.gradle
file):allprojects {
repositories {
...
mavenCentral()
}
}
dependencies {
implementation ‘com.gitee.baijuncheng-open-source:rearrangeable-layout:1.0.0'
}
All the child components are draggable once the layout is added to an ability
<com.rajasharan.layout.RearrangeableLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
xmlns:app="http://schemas.huawei.com/res/ohos-auto"
ohos:id="$+id:rearrangeable_layout"
ohos:height="match_parent"
ohos:width="match_parent"
app:outlineColor="$color:cyan"
app:outlineWidth="2vp"
app:selectionAlpha="0.5"
app:selectionZoom="1.2"
>
<Text
ohos:id="$+id:t4"
ohos:height="match_content"
ohos:width="match_content"
ohos:background_element="$color:holo_orange_light"
ohos:margin="15vp"
ohos:text="Sample"
ohos:text_size="15fp"
/>
</com.rajasharan.layout.RearrangeableLayout>
Add a ChildPositionListener to the root layout to receive updates whenever any child component is dragged
@Override
public void onStart(Intent intent) {
super.onStart(intent);
setUIContent(ResourceTable.Layout_ability_main);
root = (RearrangeableLayout) findViewById(R.id.rearrangeable_layout);
root.setChildPositionListener(new RearrangeableLayout.ChildPositionListener() {
@Override
public void onChildMoved(View childView, Rect oldPosition, Rect newPosition) {
Log.d(TAG, childView.toString());
Log.d(TAG, oldPosition.toString() + " -> " + newPosition.toString());
}
});
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。