Answer the question
In order to leave comments, you need to log in
How to create XML file with program code for multiple Activities?
I created a header for several activities, which I add to them using the include tag
. The headera code itself:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/mainlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/toolbar">
</include>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="35dp"
android:background="@color/colorRed">
<Button
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginStart="38dp"
android:layout_marginLeft="38dp"
android:background="@drawable/icon_loupe" />
<EditText
android:id="@+id/text_search"
android:layout_width="178dp"
android:layout_height="34dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="58dp"
android:layout_marginLeft="58dp"
android:layout_marginBottom="0dp"
android:background="@color/colorRed"
android:hint="@string/search"
android:inputType="text"
android:textColor="@color/colorWhite"
android:textColorHint="@color/colorWhite"
android:textSize="10sp"
android:fontFamily="@font/font_gotham_pro"
android:visibility="visible" />
</RelativeLayout>
</LinearLayout>
Answer the question
In order to leave comments, you need to log in
a couple of ideas:
- make a fragment. Write the code in a fragment.
- create a handler class, which will be delegated to handle clicks, and so on
- create a custom view. Which will be immediately inserted (instead of include)
to choose from. Based on your abilities and application requirements.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question