I have a react-native project, which has the following structure.
...
- /src
- index.js
- package.json
- App.js
- ...
- custom_file.xml
...
custom_file.xml
<LinearLayout android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/home"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="15dp"
android:layout_weight="1"
android:gravity="right|center"
android:text="Home"
android:textColor="#FFB3B3B3"
android:textSize="15sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<ImageView
android:id="@+id/homeImg"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_weight="1" />
<TextView
android:id="@+id/result"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="0:0"
android:textColor="#FFB3B3B3"
android:gravity="center"
android:textSize="15sp" />
<ImageView
android:id="@+id/awayImg"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_weight="1" />
</LinearLayout>
<TextView
android:id="@+id/away"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="15dp"
android:text="Away"
android:textColor="#FFB3B3B3"
android:gravity="left|center"
android:textSize="15sp"
/>
</LinearLayout>
I would like to understand if there is a way to make an XML format file that is found in the main structure of the app and used as a layout in this case custom_file.xml
, which over time could be modified by the programmer.
Then the android part should read this file, to use it as an example layout, before I did this:
remoteViews = new RemoteViews(reactContext.getPackageName(),R.layout.custom_notification);
I wish I could do such a thing:
//path of the file passed through javascript which is located in
//the structure of the app in react native
Object custom_notification = ""
remoteViews = new RemoteViews(reactContext.getPackageName(),custom_notification);